Unit 3 - Microcontroller
Unit 3 - Microcontroller
MICROCONTROLLER 8051
8051 Microcontroller
• Intel introduced it in the year 1981
• N-type metal-oxide-semiconductor (NMOS) based microcontroller
• Complementary metal-oxide-semiconductor(CMOS) technology
• System on a Chip (SoC) microcontroller
Issues
• Limited Memory: The program memory is typically 4 KB or 8 KB, and the data memory is typically 128 bytes or 256 bytes
• Limited Processing Power: clock speed is typically between 12 MHz and 24 MHz
• Limited Development Tools: compilers, debuggers, and simulators are not as advanced
• Limited Peripheral Support: limited number of input/output pins
• Limited Security Features: does not have hardware security features, such as memory protection and encryption
PIN Diagram
• 40 pin Dual Inline Package (DIP)
• 4 I/O ports – each port has 8 pins
– 32 out of these 40 pins are dedicated to I/O ports
• Rest of the pins are dedicated to VCC, GND, XTAL1, XTAL2, RST, ALE,
EA’ and PSEN’.
1. VCC: This pin is connected to the power supply and provides a voltage of +5V to the microcontroller.
2. GND: This pin is connected to the ground and serves as the reference voltage for the microcontroller.
3. XTAL1 and XTAL2: These pins are used for connecting an external crystal oscillator that provides the clock signal for the
microcontroller.
4. Reset: This pin is used for resetting the microcontroller. A high pulse on this pin resets the microcontroller to its initial state.
5. Port 1: This is an 8-bit bidirectional input/output port that can be used for interfacing with external devices.
6. Port 2: This is an 8-bit bidirectional input/output port that can be used for interfacing with external devices.
7. Port 3: This is an 8-bit bidirectional input/output port that can be used for interfacing with external devices.
8. Port 4: This is an 8-bit bidirectional input/output port that can be used for interfacing with external devices.
9. INT0: This is an external interrupt 0 input pin.
10. INT1: This is an external interrupt 1 input pin.
11. T0: This is an external timer 0 input pin.
12. T1: This is an external timer 1 input pin.
13. WR: This is the write signal for external memory.
14. RD: This is the read signal for external memory.
15. ALE: This is the address latch enable signal that is used to latch the address for external memory.
16. PSEN: This is the program store enable signal that is used for accessing the program memory.
17. 17-24. Address bus: These pins are used for transmitting the address information to the external memory.
18. 25-32. Data bus: These pins are used for transmitting the data between the microcontroller and external memory.
19. RST: This is the output signal that indicates the microcontroller is being reset.
20. EA: This is the external access enable signal that is used for selecting the program memory.
21. VPP: This pin is used for programming the microcontroller.
22. 36-39. XTAL: These pins are used for connecting an external crystal oscillator.
23. P1.0 (AD0) – P1.7 (AD7): These pins are used for interfacing with external analog devices.
External Memory Interfacing
• Possible to extend the memory capacity by interfacing it with RAM and ROM
• Execute larger and more complex programs, store more data, and perform more complex operations
• Connecting the memory devices to the microcontroller through a data bus and an address bus
• Data bus is used to transfer data between the microcontroller and the memory device
• Address bus is used to select a specific memory location in the memory device
• Dedicated pins such as ALE (Address Latch Enable), PSEN (Program Store Enable), and RD (Read) and WR (Write)
signals - used to control the flow of data between the microcontroller and the external memory device
• ROM serves as program memory and RAM serves as data memory
• NECESSITY of INTERFACING
Limited internal memory
Larger programs
Data storage
Flexibility
Cost-effective
External Program Memory
• The program fetches to addresses 0000H through OFFFH are directed to the internal ROM in the 8051 when the
EA pin is attached to Vcc, and
• The program fetches to addresses 1000H through FFFFH are directed to the external ROM/EPROM. When the EA
pin is grounded,
• All addresses fetched by the program (0000H to FFFFH) are led to it.
• ROM/EPROM that is external to the device. As seen in Fig. the PSEN signal is used to trigger output e external
ROM/EPROM.
• Port 0 is used as a multiplexed address/bus, as seen in Fig. In the initial T-cycle, it provides a lower order 8-bit
address, and later it is used as a data bus. The external latch and the ALE signal provided by the 8051 are used to
latch the 8-bit address.
• 1External Interrupt 0 is 0003H, Timer 0 is 000BH, External Interrupt 1 is 0013H, Timer 1 is 001BH, and so on.
• If an interrupt is to be used, the operation routine for it must be in the same place as the interrupt.
• If the interrupt isn’t used, the service location may be used as general-purpose program memory.
Instructions to Access External ROM / Program Memory
Mnemonic Operation
• Up to 64 k-bytes of additional data memory can be addressed by the 8051. The external data memory is accessed
using the “MOVX” instruction.
• The 8051’s internal data memory is split into three sections: Lower 128 bytes, Upper 128 bytes, and SFRs.
While they are physically distinct bodies, the upper addresses and SFRs share the same block of address
space, 80H by FFH.
• The upper address space is only accessible via indirect addressing, and SFRs are only accessible via direct
addressing, as seen in Higher address space, on the other hand, can be reached using either direct or indirect
addressing.
Instructions to Access External Data Memory
Mnemonic Operation
MOVX A, @Rp In this operation, it will copy the contents of the external address in Rp to A.
• In the Case of accessing external memory, All external data moves with external RAM or ROM involve the A
register.
• While accessing external memory, R can address 256 bytes and DPTR can address 64 k-bytes
• MOV X instruction is used to access external RAM or 1/O addresses.