Docsity

Microcontrollers and peripherals, Study notes of Microprocessors

Toggle sidebar
bg1
EC23C21: MICROPROCESSORS AND
MICROCONTROLLERS
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
1
Unit III : MICROCONTROLLER
1. 8051 –Architecture and pin details
2. Special Function Registers (SFRs)
3. I/O Ports, Timers / counters
4. Interrupts and serial communication
5. Instruction set
6. Addressing modes
7. Assembly language programming
TEXT BOOK
1. Kenneth J. Ayala., “The 8051 Microcontroller, 3rd Edition, Thompson Delmar Learning’’,
2012.
2. Muhammad Ali Mazidi, Janice Gillispie Mazidi and Rolin D. McKinley, "The 8051
Microcontroller and Embedded Systems", Second Edition, Pearson Education 2008.
Fifth impression 2011
Presented By,
Dr. V. Sathiesh Kumar
Department of Electronics Engg.,
MIT-Anna University
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28

Partial preview of the text

Download Microcontrollers and peripherals and more Study notes Microprocessors in PDF only on Docsity!

EC23C21: MICROPROCESSORS AND

MICROCONTROLLERS

1

Unit III : MICROCONTROLLER

1. 8051 – Architecture and pin details

2. Special Function Registers (SFRs)

3. I/O Ports, Timers / counters

4. Interrupts and serial communication

5. Instruction set

6. Addressing modes

7. Assembly language programming

TEXT BOOK

  1. Kenneth J. Ayala., “The 8051 Microcontroller, 3 rd Edition, Thompson Delmar Learning’’,
  2. Muhammad Ali Mazidi, Janice Gillispie Mazidi and Rolin D. McKinley, "The 8051 Microcontroller and Embedded Systems", Second Edition, Pearson Education 2008. Fifth impression 2011

Presented By,

Dr. V. Sathiesh Kumar

Department of Electronics Engg., MIT-Anna University

2 8051 Microcontroller:

  • In 1981 , Intel introduced an 8 - bit microcontroller called the 8051.
  • It was referred as system on a chip because it had 128 bytes of RAM , 4 K byte of on- chip ROM , two timers , one serial port , and 4 ports ( 8 - bit wide), all on a single chip. Feature 8051 8052 8031 ROM(bytes) 4K 8K 0K RAM(bytes) 128 256 128 Timers 2 3 2 I/O pins 32 32 32 Serial port 1 1 1 Interrupt sources 6 8 6

4 8051 Microcontroller: Block Diagram

5 8051 Microcontroller: Architecture

7 8051 Microcontroller: Pin Details

  • In 8051 , I/O operations are done using four ports and 40 pins.
  • I/O operation port reserves 32 pins where each port has 8 pins.
  • The other 8 pins are designated as Vcc, GND, XTAL 1 , XTAL 2 , RST, EA, ALE/PROG,** and PSEN*. 8051

8 8051 Microcontroller: Pin Details - I/O Port and their functions

  • The four ports P 0 , P 1 , P 2 , and P 3 , each use 8 pins, making them 8 - bit ports.
  • Upon RESET , all the ports are configured as inputs , ready to be used as input ports.
  • When the first 0 is written to a port, it becomes an output.
  • To reconfigure it as an input, a 1 must be sent to a port. Port 0 (Pin No 32 – Pin No 39 ):
  • It has 8 pins ( 32 to 39 ).
  • It can be used for input or output.
  • Unlike P 1 , P 2 , and P 3 ports, we normally connect P 0 to 10 K-ohm pull-up resistors to use it as an input or output port being an open drain.
  • It is also designated as AD 0 - AD 7 , allowing it to be used as both address and data.
  • ALE (Pin no 31 ) indicates if P 0 has address or data.
  • When ALE = 0 , it provides data D 0 - D 7 , but when ALE = 1 , it has address A 0 - A 7.

10 8051 Microcontroller: Pin Details - I/O Port and their functions Port 1 (Pin No 1 – Pin No 8 ):

  • It is an 8 - bit port (pin 1 through 8 ) and can be used either as input or output.
  • It doesn't require pull-up resistors because they are already connected internally.
  • Upon RESET, Port 1 is configured as an input port.
  • If Port 1 is configured to be used as an output port, then to use it as an input port again, program it by writing 1 to all of its bits. Port 2 (Pins 21 through 28):
  • Port 2 occupies a total of 8 pins (pins 21 through 28 ) and can be used for both input and output operations.
  • P 2 also doesn't require external Pull-up resistors because they are already connected internally.
  • It must be used along with P 0 to provide the 16 - bit address for the external memory.

11 8051 Microcontroller: Pin Details - I/O Port and their functions

  • When the 8051 is connected to an external memory , it provides path for upper 8 - bits of 16 - bits address, and it cannot be used as I/O.
  • Upon RESET, Port 2 is configured as an input port.
  • If Port 2 is configured to be used as an output port, then to use it as an input port again, program it by writing 1 to all of its bits. Port 3 (Pins 10 through 17):
  • It is also of 8 bits and can be used as Input/Output.
  • P 3. 0 and P 3. 1 are RxD (Receiver) and TxD (Transmitter) , respectively and are collectively used for Serial Communication.
  • P 3. 2 and P 3. 3 pins are used for external interrupts.
  • P 3. 4 and P 3. 5 are used for timers T 0 and T 1 , respectively.
  • P 3. 6 and P 3. 7 are Write (WR)* and Read (RD)* pins.

13 8051 Microcontroller: Pin Details - I/O Port and their functions RST (Pin No. 9 ) : It is an Input pin and active High pin.

  • Upon applying a high pulse on this pin, that is 1 , the microcontroller will reset and terminate all activities. This process is known as Power-On Reset.
  • Activating a power-on reset will cause all values in the register to be lost. It will set a program counter to all 0 's.
  • To ensure a valid input of Reset , the high pulse must be high for a minimum of two machine cycles before it is allowed to go low.

14 8051 Microcontroller: Pin Details - I/O Port and their functions EA or External Access (Pin No. 31 )* : It is an input pin.

  • This pin is an active low pin ; upon applying a low pulse, it gets activated.
  • In case of microcontroller ( 8051 / 52 ) having on-chip ROM , the EA pin is connected to Vcc*.
  • But in an 8031 microcontroller which does not have an on-chip ROM, the code is stored in an external ROM and then fetched by the microcontroller. In this case, we must connect the (pin no 31 ) EA to GND to indicate that the program code is stored externally*.

16 8051 Microcontroller: Little Endian vs Big Endian

  • Although numbers are always displayed in the same way , they are not stored in the same way in memory.
  • Big-Endian machines store the most significant byte of data in the lowest memory address.
  • A Big-Endian machine stores 0 x 12345678 as − ADD+ 0 : 0 x 12 ADD+ 1 : 0 x 34 ADD+ 2 : 0 x 56 ADD+ 3 : 0 x 78

17 8051 Microcontroller: Little Endian vs Big Endian

  • Little-Endian machines, on the other hand, store the least significant byte of data in the lowest memory address.
  • A Little-Endian machine stores 0 x 12345678 as, ADD+ 0 : 0 x 78 ADD+ 1 : 0 x 56 ADD+ 2 : 0 x 34 ADD+ 3 : 0 x 12

19 8051 Microcontroller: Registers

20 8051 Microcontroller: Registers Accumulator (A):

  • The accumulator, register A, is used for all arithmetic and logic operations.
  • If the accumulator is not present, then every result of each calculation (addition, multiplication, shift, etc.) is to be stored into the main memory.
  • Access to main memory is slower than access to a register like the accumulator because the technology used for the large main memory is slower (but cheaper) than that used for a register. The ‘R’ Registers:
  • The ‘R’ registers are a set of eight registers , namely, R 0 , R 1 to R 7.
  • These registers function as auxiliary or temporary storage registers in many operations.