8051 Microcontroller: Presented By, Er. Swapnil Kaware, B.E. (Electronics), Svkaware@yahoo - Co.in
8051 Microcontroller: Presented By, Er. Swapnil Kaware, B.E. (Electronics), Svkaware@yahoo - Co.in
8051 Microcontroller: Presented By, Er. Swapnil Kaware, B.E. (Electronics), Svkaware@yahoo - Co.in
Presented By, Click to edit Master subtitle style Er. Swapnil Kaware, B.E. (Electronics), [email protected]
6/14/12
11
Salient Features
(1). 8 bit microcontroller originally developed by Intel in 1980. (2). High-performance CMOS Technology. (3). Contains Total 40 pins. (4). Address bus is of 16 bit & data bus is of 8 bit. (5). 4K bytes internal ROM (program). (6). 128 bytes internal RAM (data). (7). Four 8-bit I/O ports. (8). Two 16-bit timers. (9). Serial interface Communication. (10). 64K external code & data memory space. (11). 210 bit-addressable locations. (12). Internal memory consists of on-chip ROM and on-chip data RAM. (13). 8051 implements a separate memory space for programs (code) and data. (14). Operating frequency is 24MHz-33MHz. 6/14/12
22
6/14/12
33
Internal Architecture
Oscillator Circuit:(1). The 8051 requires an external oscillator circuit. (2). The oscillator circuit usually runs around 12MHz. (3). The crystal generates 12M pulses in one second. (4). The pulse is used to synchronize the system operation in a controlled pace. (5). An 8051 machine cycle consists of 12 crystal pulses (clock cycle). 6/14/12 44
Internal Memory
(1). 8051 implements a separate memory space for programs (code) and data.
(2). Both code and data may be internal, however, both expand using external components to a maximum of 64K code memory and 64K data memory.
(3). Internal memory consists of on-chip ROM and on-chip data RAM.
(4). On-chip RAM contains a rich arrangement of general purpose storage, bit addressable storage, register banks, and special function registers. 6/14/12 55 (5). In the 8051, the registers and input/output ports are memory
6/14/12
66
6/14/12
77
(1). 8051 has 21 special function registers (SFRs) at the top of internal RAM from address 80H to FFH.
(2). Most of the addresses from 80H to FFH are not defined, except for 21 of them.
(3). Some SFRs are both bit-addressable and byte addressable, depending on the instruction accessing the register.
B Register
(1). B register or accumulator B is used along with the accumulator for multiply and divide operations. (2). MUL AB: multiplies 8 bit unsigned values in A and B. and leaves the 16 bit result in A (low byte) and B (high byte). (3). DIV AB: divided A by B, leaving the integer result in A and remainder in B. (4). B register is bit-addressable. 6/14/12
1010
6/14/12
1111
Stack Pointer
(1). Stack pointer (SP) is an 8-bit register at address 81H. (2). It contains the address of the data item currently on top of the stack. (3). Stack operations include pushing data on the stack andpopping data off the stack. (4). Pushing increments SP before writing the data (5). Popping from the stack reads the data and decrements the SP (6). 8051 stack is kept in the internal RAM (7). Depending on the initial value of the SP, stack 6/14/12 1212
I/O Ports
(1). One of the major features of a microcontroller is the versatility built into the I/O circuits that connect the microcontroller to the outside world . (2). To be commercially viable, the 8051 had to incorporate as many I/O functions as were technically and economically possible. (3). One of the most useful features of the 8051 is four bidirectional I/O ports. (4). Each port has an 8-bit latch in the SFR space as mentioned earlier. (5). To reduce the overall package pin count, the 8051 employs multiple functions for each port. (6). Each port also has an output drive and an input buffer. (7). These ports can be used to general purpose I/O, as an
6/14/12 1414
I/O Ports
6/14/12
1515
PORT 0
(1). Port 0 is 8-bitbidirectional I/O port. (2). Port 0 pins can be used as highimpedance inputs. (3). Port 0 is also the multiplexed loworder address and data bus during accesses to external program and data memory.
6/14/12 1616
PORT 1
(1). Port 1 is an 8-bit bidirectional I/0 port. (2). We r using pins no. from 1 to 9. (3). Port 1 have no dual functions. (4). When used as an output the pin 6/14/12 1717
PORT 2
(1). Port 2 is an 8-bit bidirectional I/O port.
(2). Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @DPTR).
PORT 3
(1). Port 3 is an 8-bit bi-directional I/0 port. (2). We r using pins no. from 10 to 17. RXD (P3.0): Serial input port, TXD (P3.1): Serial output port, INT0 (P3.2): External interrupt, INT1 (P3.3): External interrupt, T0 T0 (P3.4): Timer 0 external input, T1 (P3.5): Timer 1 external input, WR (P3.6): External data memory write strobe, 6/14/12 1919
(3). The 8051 has two 16-bit registers that can be used as either timers or counters.
(4). These two up counters are name T0 and T1 and are provided for general use of the programmer.
(5). Each counter may be programmed to count internal clock 6/14/12 2020 pulses, act as a timer, or programmed to count external events as a
6/14/12
2121
6/14/12
2222
6/14/12
2323
6/14/12
2424
Interrupts
An interrupt is a special feature which Allows the 8051 to provide the illusion of "multitasking, although in reality the 8051 is only doing one thing at a time. The word "interrupt" can often be substituted with the word "event.
An interrupt is triggered whenever corresponding event occurs. When the event occurs, the 8051 temporarily puts "on hold" the normal execution of the program and executes a special section of code referred to as an interrupt handler.
Whenever any device needs its service, the device notifies the microcontroller by sending it an interrupt signal.
There are total 5 interrupt sources in 8051 Microprocessor as 6/14/12 2525 follows.
Interrupts Priorities
Interrupt Destinations
Interrupt Address (Hex) 1 IE0 0003H 2 3 4 5
6/14/12
6/14/12
2727
6/14/12
2828
END OF SESSION
6/14/12 2929