3. Overview of 8051
MCU
The 8051 Microcontroller (MCU)
is an 8-bit microcontroller
developed by Intel in 1980 for
embedded systems. It is widely
used in industrial, consumer, and
automotive applications due to
its simplicity and efficiency.
4. Overview of 8051 MCU
Features of 8051 MCU:
8-bit CPU: Can process 8-bit data at a time.
Memory:
4KB ROM (on-chip program memory)
128 bytes RAM (on-chip data memory)
I/O Ports: 32 programmable I/O pins (4 ports: P0,
P1, P2, P3).
Timers & Counters: Two 16-bit timers/counters
(T0, T1).
Serial Communication: Supports UART
(Universal Asynchronous Receiver-Transmitter).
Interrupts: 5 interrupt sources (external and
internal).
Clock Speed: Typically runs at 12 MHz (requires
an external crystal oscillator).
5. Applications of 8051
MCU
Embedded systems
Robotics
Home automation
Industrial automation
Consumer electronics
Medical devices
7. Architectural Components of 8051
The 8051 consists of the following key
components:
Central Processing Unit (CPU)
Memory (ROM & RAM)
I/O Ports
Timers/Counters
Interrupt System
Serial Communication
Oscillator & Clock Circuit
9. Architectural Components of 8051
Central Processing Unit (CPU)
The CPU processes instructions fetched from ROM and executes them
sequentially. It controls the overall operation of the microcontroller.
Memory Organization
The 8051 has separate memory spaces for program and data.
10. Architectural Components of 8051
Program Memory (ROM)
4KB on-chip ROM for storing program instructions.
Can be extended up to 64KB externally.
Data Memory (RAM)
128 bytes on-chip RAM used for storing temporary data. Divided
into 32 General-purpose Registers (R0–R7) (Working Registers),
16-bit Stack Pointer (SP), Bit-addressable Memory (16 bytes, 128
bits), Special Function Registers (SFRs) for controlling peripherals.
11. Architectural Components of 8051
I/O Ports
32 I/O pins, grouped into four 8-bit parallel ports (P0, P1, P2, P3).
Port 0 (P0): Acts as both general-purpose I/O and lower-order
address/data bus in external memory interfacing.
Port 1 (P1): General-purpose I/O.
Port 2 (P2): Higher-order address bus for external memory.
Port 3 (P3): Dual function port (I/O and special functions like
interrupts, serial communication).
12. Architectural Components of 8051
Timers and Counters
8051 has two 16-bit timers/counters (Timer 0 & Timer 1). Used for Time
delays, Event counting, Generating baud rates for serial communication.
Interrupt System
Supports 5 interrupts:
a) 2 External Interrupts (INT0, INT1)
b) 2 Timer Interrupts (Timer 0, Timer 1)
c) 1 Serial Interrupt (RI/TI for serial communication)
13. Architectural Components of 8051
Serial Communication
Supports UART (Universal Asynchronous Receiver Transmitter).
Uses SBUF (Serial Buffer Register) for transmission/reception. Baud
rate controlled by Timer 1.
Oscillator and Clock Circuit
•Requires an external crystal oscillator (typically 12 MHz).
•Clock speed determines the instruction execution time.
•One machine cycle = 12 clock cycles.
16. Pin Descriptions and Functions
1. Power Supply Pins
VCC (Pin 40): +5V power supply.
GND (Pin 20): Ground reference.
2. Oscillator Pins
XTAL1 (Pin 19): Input to the inverting oscillator amplifier.
XTAL2 (Pin 18): Output from the inverting oscillator amplifier.
A 12 MHz crystal oscillator is commonly used to generate the
clock signal.
17. Pin Descriptions and Functions
3. Reset Pin
RST (Pin 9):
o Active high reset input.
o A high pulse (>2 machine cycles) resets
the microcontroller.
o Used to initialize registers and program
execution.
18. Pin Descriptions and Functions
4. Input/Output (I/O) Ports
The 8051 has 4 I/O ports (P0, P1, P2, P3), each with 8 bidirectional pins.
Port 1 (Pins 1-8)
[P1.0 - P1.7]
Dedicated I/O port (No alternate
function).
Internal pull-up resistors available.
Used for interfacing LEDs, sensors,
relays, etc..
Port 0 (Pins 32-39)
[P0.0 - P0.7]
Dual-purpose port:
General I/O mode: Acts as an 8-bit bidirectional
data port.
External Memory Mode: Works as Address/Data
bus (AD0-AD7).
Requires pull-up resistors when used for general
I/O.
19. Pin Descriptions and Functions
Port 3 (Pins 10-17)
[P3.0 - P3.7]
Each pin has a secondary function:
P3.0 (RXD, Pin 10) – Serial Input (UART receive).
P3.1 (TXD, Pin 11) – Serial Output (UART transmit).
P3.2 (INT0, Pin 12) – External Interrupt 0.
P3.3 (INT1, Pin 13) – External Interrupt 1.
P3.4 (T0, Pin 14) – Timer 0 input.
P3.5 (T1, Pin 15) – Timer 1 input.
P3.6 (WR, Pin 16) – Write signal for external memory.
P3.7 (RD, Pin 17) – Read signal for external memory.
Port 2 (Pins 21-28)
[P2.0 - P2.7]
Dual-purpose port:
General-purpose I/O and Higher-order
address bus (A8–A15) when interfacing
external memory.
Internal pull-ups are present.
20. Pin Descriptions and Functions
5. Control Pins
These pins are used when interfacing external memory.
EA (Pin 31) – External Access
o EA = 1 → Access internal ROM (default).
o EA = 0 → Access external ROM (up to 64KB).
ALE (Pin 30) – Address Latch Enable
o Used to demultiplex address and data signals from Port 0.
o Provides a clock pulse for external memory interfacing.
PSEN (Pin 29) – Program Store Enable
o PSEN = 0 → Microcontroller reads from external program memory.
o Used when external ROM is required.
21. Pin Descriptions and Functions
6. Read/Write Control Pins
Used when interfacing external RAM/ROM.
WR (Write, Pin 16):
o Low (0): Enables write operation to
external memory.
RD (Read, Pin 17):
o Low (0): Enables read operation from
external memory.
24. External Memory Interfacing in 8051
External ROM Interfacing (Program
Memory)
Used when code exceeds 4KB internal ROM.
PSEN (Program Store Enable) is used to access external ROM.
Address & Data Bus:
• Port 0 (P0) → Multiplexed Address/Data Bus (AD0–AD7)
• Port 2 (P2) → Higher Address Lines (A8–A15)
• ALE (Address Latch Enable) is used to demultiplex the
address and data.
25. External Memory Interfacing in 8051
8051 Pin ROM Pin
P0.0 – P0.7 AD0 – AD7 (Address/Data)
P2.0 – P2.3 A8 – A11
PSEN OE (Output Enable)
ALE Latch Control
26. External Memory Interfacing in 8051
External RAM Interfacing (Data Memory)
Used when data exceeds 128 bytes of internal RAM.
RD (Read) & WR (Write) control external RAM.
Addressing range up to 64KB.
8051 uses MOVX instruction to access external RAM.
29. Communication with 8051
Microcontroller
The 8051 microcontroller supports various
communication protocols for data transfer
between devices. These communication methods
include serial communication (UART), I2C, SPI,
and parallel communication (GPIO-based).
Each method is suited for different applications,
such as interfacing with sensors, displays,
memory devices, and wireless modules.
30. Communication with 8051
Microcontroller
UART (Universal Asynchronous Receiver-Transmitter) is
the most commonly used communication method in 8051,
allowing data transmission over a single wire (TX/RX).
Features of UART in 8051:
1. Supports full-duplex communication.
2. Uses TX (Transmit) and RX (Receive) pins.
3. Baud rate is programmable using Timer 1.
4. Uses SBUF (Serial Buffer Register) for transmission/reception.
5. SCON (Serial Control Register) controls the mode of operation.
Pin Function
P3.0 (RXD) Serial data input (Receives data)
P3.1 (TXD) Serial data output (Transmits data)
31. Communication with 8051
Microcontroller
I2C (Inter-Integrated Circuit) is a synchronous, multi-master,
multi-slave communication protocol used for EEPROM,
sensors, and RTC modules.
I2C Features:
Uses 2 wires: SCL (Clock) & SDA (Data).
Supports multiple slave devices.
Serial data transmission with start and stop conditions.
Each device has a unique 7-bit or 10-bit address.
Pin Function
P1.6 SCL (Serial Clock Line)
P1.7 SDA (Serial Data Line)
32. Communication with 8051
Microcontroller
SPI (Serial Peripheral Interface) is a synchronous,
high-speed serial communication protocol.
SPI Features:
Uses 4 lines:
• MOSI (Master Out Slave In)
• MISO (Master In Slave Out)
• SCK (Serial Clock)
• SS (Slave Select)
Fast communication for ADC, DAC, SD cards.
Pin Function
P1.5 MOSI (Data Out)
P1.6 MISO (Data In)
P1.7 SCK (Clock)
P3.5 SS (Chip Select)
33. Communication with 8051
Microcontroller
Parallel Communication (GPIO)
Directly controlled via I/O ports (P0, P1, P2, P3).
Fastest method but requires more pins.
Used for LCD, Keypad, Motors, LEDs.
Example: Interfacing 16x2 LCD via Parallel Communication