8051 Microcontroller: Chapter - 2
8051 Microcontroller: Chapter - 2
8051 MICROCONTROLLER
By
Mr. Sandeep Chintoju
CHAPTER 2
The 8051 Architecture
8051 Microcontroller -
Pin Diagram
Input/output Ports
(P0, P1, P2, P3)
Memory Organization
Counter and Timers
(TMOD, TCON)
Serial data
Input/output
(SMOD, SCON, PCON)
Interrupts
(IE, IP)
Brief History of 8051
• The first microprocessor 4004 was invented by Intel
Corporation. 8085 and 8086 microprocessors were also
invented by Intel.
• 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, 4K byte of on-chip ROM, two timers, one
serial port, and 4 ports (8-bit wide), all on a single chip.
• When it became widely popular, Intel allowed other
manufacturers to make and market different flavors of
8051 with its code compatible with 8051.
• It means that if you write your program for one flavor of
8051, it will run on other flavors too, regardless of the
manufacturer.
• This has led to several versions with different speeds and
amounts of on-chip RAM.
MICROCONTROLLER – 8051
Intel introduced 8051, referred as MCS-51, in
1981
The 8051 is an 8-bit microcontroller
ƒThe CPU can work on only 8 bits of data at a
time.
The 8051 had
ƒ 128 bytes of on-chip RAM
ƒ 4K bytes of on-chip ROM
ƒ Two timers
ƒ One serial port
ƒ Four I/O ports, each 8 bits wide
ƒ 5 interrupt sources
Various 8051 Microcontrollers
Various 8051 Microcontrollers (cont’)
Block Diagram of 8051 MC
External interrupts
On-chip Timer/Counter
CPU
Bus Serial
4 I/O Ports
OSC Control Port
P0 P1 P2 P3 TxD RxD
Address/Data
Features of 8051 Microcontroller
An 8051 microcontroller comes bundled with the following features
• 4KB bytes on-chip program memory (ROM)
• 128 bytes on-chip data memory (RAM)
• Four register banks (RB0, RB1, RB2, RB3)
• 8-bit bidirectional data bus
• 16-bit unidirectional address bus
• 32 general purpose registers + A reg + B reg each of 8-bit
• Two 16 bit Timers (T0 & T1)
• Five Six Interrupts (Three internal + two external Interrupts +
RESET)
• Four 8-bit ports (P0, P1, P2, P3)
• 16-bit program counter (PC) and 16-bit data pointer (DPTR)
• Full Duplex serial data transmitter and receiver (SBUF)
• Control registers (TMOD, TCON, SCON, PCON, IE, IP)
• The system bus connects all the support
devices to the CPU.
• The system bus consists of an 8-bit data bus, a
16-bit address bus and bus control signals.
• All other devices like program memory, ports,
data memory, serial interface, interrupt
control, timers, and the CPU are all interfaced
together through the system bus.
Architecture of 8051 MC
8051 Pin Diagram
Pin Description of 8051
P3.0 RxD 10
P3.1 TxD 11
P3.2 INT0 12
P3.3 INT1 13
P3.4 T0 14
P3.5 T1 15
P3.6 WR 16
P3.7 RD 17
Pin Description of 8051 (cont’)
C2
XTAL2
30pF
C1
XTAL1
30pF
GND
Pin Description of 8051 (cont’)
A
B
R0
DPTR DPH DPL
R1
R2 PC PC
R3
R4 8051 16-bit Register
R5
R6
R7
Some 8-bit
Registers of the
8051
MEMORY ORGANIZATION
ROM Memory mapping in 8051
4K Bytes
• 8051 has 4K bytes of ROM
0000H
• This is used for storing the program
code
0FFFH
• It is also known as program memory
8751
ranging from 0000H to FFFFH AT89C51
• This memory is accessed by “program
counter”
• EA pin which stands for External Access input.
• EA is used to enable/disable the external memory
interfacing.
If EA = 0 –> Only external 64KB is accessed by PC
If EA = 1 –> 4KB of internal RAM and 60KB of
external ROM will be accessed
0000H 0000H
ON CHIP
ROM (4KB)
0FFFH
OFF CHIP
1000H
ROM
(64 KB) OFF CHIP
ROM
(60 KB)
FFFFH FFFFH
If EA = 0 If EA = 1
128 Bytes RAM memory space allocation in the 8051
7FH
30H
2FH
Addressable at Bit-Addressable RAM
16 bytes
bit level
20H
1FH
8 bytes Register Bank 3
18H
4 Register Banks 17H
each containing 8 bytes Register Bank 2
10H
8 registers 0FH
(R0 – R7 each of 8 bytes Register Bank 1 (Stack)
08H
8 bits) 07H 8 bytes Register Bank 0
00H
Internal RAM Organization
Bit Addressable RAM
Processor Status Word (PSW)
• Processor Status Word (PSW) register is an 8-
bit register, it is also referred to as the flag
register.
8051 Timers/Counters
TMOD Register
TMOD is not bit addressable register
the lower two bits (M0, M1) are used to set the timer mode
the upper two bits (GATE, C/T’) are used to specify operation
SMOD BIT
INTERRUPTS
• An interrupt is an external or internal event that interrupts the
microcontroller to inform it that a device needs its service.
• The 8051 has six interrupts based on manufacturers data sheet.
They are:
1) RESET (pin 9)
2) Two from the timer/counter overflow flags (TF0 & TF1)
3) Two from external interrupt inputs (INT0 & INT1)
P3.2 and P3.3 are for the external hardware interrupts INT0
and INT1
4) One from serial port (TI/RI) for transfer or receive (Serial
communication has a single interrupt that belongs to both receive
and transfer)
Six Interrupts in 8051 - IVT
• A single microcontroller can serve several
devices by two ways:
1) Interrupts method and
2) Polling method
• Polling method