BCSE305L - Embedded Systems
Module 1
Topic: 8051 Microcontroller Architecture
Microcontroller
Microcontroller
• A micro-controller is a very powerful device, which is capable of executing a series of
pre-programmed tasks and interacting with other hardware devices
• Being packed in a tiny integrated circuit (IC) whose size and weight is usually negligible,
• It is becoming the perfect controller for robots or any machines requiring some kind of
intelligent automation. A single microcontroller can be sufficient to control a small mobile
robot, an automatic washer machine or a security system.
• Any microcontroller contains a memory to store the program to be executed, Number of
input/output lines that can be used to interact with other devices, like reading the state of
a sensor or controlling a motor.
• Most recent microcontrollers are 'In System Programmable',
– End user can modify the program being executed, without removing the microcontroller
from its place.
Three criteria in Choosing a Microcontroller
• Meeting the computing needs of the task efficiently and cost effectively
– speed, the amount of ROM and RAM, the number of I/O ports and timers, size,
packaging, power consumption
– easy to upgrade
– cost per unit
– Noise of environment
– Power consumption
• Availability of software development tools
– assemblers, debuggers, C compilers, emulator, simulator, technical support
• Wide availability and reliable sources of the microcontrollers
– Intel, Atmel, Philips / Signetics, Infineon, Dallas Semi/ Maxim
8051
Foot Print
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)P3.0
(TXD)P3.1
(INT0)P3.2
(INT1)P3.3
(T0)P3.4
(T1)P3.5
(WR)P3.6
(RD)P3.7
XTAL2
XTAL1
GND
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
8051
(8031)
(8751)
(8951)
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
EA/VPP
ALE/PROG
PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
Features of 8051
➢8051 is a 8 bit microcontroller
➢8051 has 16 address lines
➢It has on chip 4KB ROM(Programming memory)
➢It has 128 bytes of on chip RAM (Data Memory)
➢16 memory location of data memory are bit/byte addressable
➢The data/Program memory can be expanded up to 64KB
➢It has 4 parallel I/O port: Port 0, Port 1, Port 2, Port 3.Each port is a 8 bit
directional I/O port. Each port is bit/byte addressable
➢It has two 16 bit multi mode programmable timer/counter
➢It has multi mode high speed programmable full duplex serial port
➢It has 5 hardware interrupts: 3 internal interrupt and 2 external
interrupt(TM0,TM1, TI/RI, INT0, INT1)
➢It has on chip power saving circuit operated in 2 modes1. Idle mode 2. Power
down mode
Other Features of 8051
➢only 1 On chip oscillator (external crystal)
➢5 interrupt sources (2 external , 3 internal)
➢64K external code (program) memory(only read)PSEN (Used
when the 8051 fetches instructions from external program
memory(ROM)
➢64K external data memory(can be read and write) by RD,WR
➢Code memory is selectable by EA (internal or external)
Important Pins (IO Ports)
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)P3.0
(TXD)P3.1
(INT0)P3.2
(INT1)P3.3
(T0)P3.4
(T1)P3.5
(WR)P3.6
(RD)P3.7
XTAL2
XTAL1
GND
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
8051
(8031)
(8751)
(8951)
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
➢One of the most useful features
of the 8051 is that it contains four
I/O ports (P0 - P3) Each port can
be used as input or output (bidirection)
EA/VPP
ALE/PROG
PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
Port 0
pins 32-39 (P0.0~P0.7)
– 8-bit R/W - General Purpose
I/O
– Or acts as a multiplexed low byte
address and data bus for external
memory design
Important Pins (IO Ports)
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)P3.0
(TXD)P3.1
(INT0)P3.2
(INT1)P3.3
(T0)P3.4
(T1)P3.5
(WR)P3.6
(RD)P3.7
XTAL2
XTAL1
GND
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
8051
(8031)
(8751)
(8951)
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
EA/VPP
ALE/PROG
PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
Port 2
pins 21-28(P2.0~ P2.7)
– 8-bit R/W - General
Purpose I/O
– Or high byte of the address
bus for external memory
design
Important Pins (IO Ports)
Port 3
Port 1
pins 10-17 (P3.0~P3.7)
(pins 1-8)(P1.0~P1.7)
– General Purpose I/O
– Only 8-bit R/W – if not using any of the internal
General Purpose I/O
peripherals (timers) or external
interrupts.
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)P3.0
(TXD)P3.1
(INT0)P3.2
(INT1)P3.3
(T0)P3.4
(T1)P3.5
(WR)P3.6
(RD)P3.7
XTAL2
XTAL1
GND
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
8051
(8031)
(8751)
(8951)
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
EA/VPP
ALE/PROG
PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
Important Pins (IO Ports)
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)P3.0
(TXD)P3.1
(INT0)P3.2
(INT1)P3.3
(T0)P3.4
(T1)P3.5
(WR)P3.6
(RD)P3.7
XTAL2
XTAL1
GND
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
8051
(8031)
(8751)
(8951)
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
EA/VPP
ALE/PROG
PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
PSEN (out): Program Store
Enable
• Active low
• Used when the 8051 fetches
instructions from external
program
memory(ROM/EPROM).
• Read signal for external program
memory (active low).
Important Pins (IO Ports)
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)P3.0
(TXD)P3.1
(INT0)P3.2
(INT1)P3.3
(T0)P3.4
(T1)P3.5
(WR)P3.6
(RD)P3.7
XTAL2
XTAL1
GND
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
8051
(8031)
(8751)
(8951)
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
EA/VPP
ALE/PROG
PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
EA (in): External Access Enable
• It decides whether the 8051 will
fetch program instructions from
internal memory or external
memory.
• Active low
• There is no on-chip ROM in 8031
and 8032 .
• The /EA pin is connected to GND to
indicate the code is stored externally.
• /PSEN &ALE are used for external
ROM.
• If external memory is not used , /EA
pin is connected to Vcc.
Important Pins (IO Ports)
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)P3.0
(TXD)P3.1
(INT0)P3.2
(INT1)P3.3
(T0)P3.4
(T1)P3.5
(WR)P3.6
(RD)P3.7
XTAL2
XTAL1
GND
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
8051
(8031)
(8751)
(8951)
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
EA/VPP
ALE/PROG
PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
Vcc(pin 40):
– Vcc provides supply voltage to
the chip.
– The voltage source is +5V.
ALE (out): Address Latch Enable
to latch address outputs at Port0 and Port2
It is an output pin and is active high.
8051 port 0 provides both address and data
Important Pins (IO Ports)
XTAL1 & XTAL2: Crystal inputs for
internal oscillator.
XTAL1 and XTAL2(pins 19,18):
– These 2 pins provide external
clock.
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)P3.0
(TXD)P3.1
(INT0)P3.2
(INT1)P3.3
(T0)P3.4
(T1)P3.5
(WR)P3.6
(RD)P3.7
XTAL2
• GND(pin 20):ground
XTAL1
GND
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
8051
(8031)
(8751)
(8951)
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
EA/VPP
ALE/PROG
PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
Components of 8051 (CPU & RAM)
➢Microcontroller 8051 has a central processing unit which is also called ALU
(Arithmetic Logic Unit) which performs all arithmetic and logical operation.
➢RAM
• Microcontroller 8051 has 128-byte RAM for data storage.
• It is a Volatile type of memory. That means the data is lost when power to the
device is turned off.
• It is used during execution time to store data temporarily.
• RAM consists of a register bank, stack, and temporary data storage with some
special function registers (SFR’s).
➢ROM
Components of 8051 -ROM
• In 8051, 4KB ROM is available for program storage.
• It is a Non-Volatile type of memory. It means that data is not lost even in the
event of power failure.
• 8051 has a 16-bit address. It means it can access 2^16 memory locations and
we can interface up to 64 KB of program memory externally in case of large
applications.
Oscillator
➢it is used to provide a clock to the 8051 which decides the speed and baud
rate. (number of bits sent per second.)
➢We use crystals of frequency varying from 4MHz to 30 MHz. Normally we
use 11.0592 MHz frequency which is required for a 9600 baud rate in serial
communication.
8051 Timers and Counters
•
•
•
•
Microcontroller 8051 has two timer pins T0 and T1
By these timers, we can generate a delay of a particular time in timer mode
We can count external pulses or events in counter mode
Two 16-bit timer registers are available as T0 (TH0 & TL0) and T1 (TH1 & TL1), e.g. If
we want to load T0 then we can load Higher 8-bit in TH0 & Lower 8-bit in TL0
• TMOD and TCON registers are used to select mode and control the timer operation
8051 Interrupts
• Interrupts are requested by internal or external peripherals which are masked while unused.
• Interrupt handler routines are called after each interrupts event occurs.
• These routines are called an Interrupt Service Routine (ISR) and are located in special
memory loc.
• INT0 and INT1 pins used to accept external interrupts.
8051 I/O Ports
➢8051 Microcontroller has four Input/output ports P0, P1, P2, P3
➢Each port is 8-bit wide and their SFR (P0, P1, P2, P3) are bit accessible i.e. we can set or reset
individual bits.
➢Some ports have dual functionality on their pins as,
➢P0 I/O pins are multiplexed with an 8-bit data bus and lower order address bus (AD0-AD7) which are
de-multiplexed by ALE signal and latch used in external memory access operation.
➢P2 I/O pins are multiplexed with the remaining higher order address bus (A8-A15)
➢P3 I/O pins also have dual functions as,
• P3.0 – RXD – Serial data receive.
• P3.1 – TXD – Serial data transmit.
• P3.2 – INT0 – External Interrupt 0.
• P3.3 – INT1 – External Interrupt 1.
• P3.4 – T0 – Clock input for counter 0.
• P3.5 – T1 – Clock input for counter 1.
• P3.6 – WR – Signal for writing to external memory.
• P3.7 – RD – Signal for reading from external memory.
• P0 and P2 can’t be used as I/O pins in the external memory access operation
8051 Serial Communication
• 8051 MCU has two serial communication (UART) pins TXD and RXD used for
transmitting and receive data serially via the SBUF register (Serial Buffer)
• SCON SFR used to control serial operation
ALE
Port 0 of 8051 is multiplexed: it carries both
❖ Low byte of address (A0–A7)
❖ Data (D0–D7)
If we don’t separate address and data, the external memory cannot
distinguish between them.
ALE signals an external latch to capture the low byte of address when needed.
8051 Architecture Block
8051 Microcontroller Applications
❖ Automobile applications
❖ Temperature sensing and controlling devices
❖ Defense applications,
❖ Fire detection and safety devices
❖ Light sensing tools.
Other applications of this controller include
❖ Touch screens
❖ Medical devices
❖ Robotics
❖ Remote sensing
❖ Home appliances, etc
2. ALE̅ (Address Latch Enable)