0a. 8051 Architecture
0a. 8051 Architecture
1
Components of Embedded Systems
Communication
Power Supply Processor Memory Timers & Counters
Ports
••Stable UART
Power
Speed Supply Output
& Smooth ••Load
RS-423
Number – Fluctuation
of I/O
Regulation Pins in output voltage when
•••Proper
CAN
Processor
Read-Only
Unit Price memory(RAM)
Output
Assembler Current to Drive the Load ••load
RS-485
Power Consumption
current changes
••Perfect
SPI
Display
Random
PackagingDevice
Power
Emulator Access Memory(ROM)
Efficiency •Efficiency
UART
Amount of RAM and ROM
••Stable
I2C
Buzzer for Alert
Electrically
Performance Erasable
in Different
Debugger Programmable
Temperature Range Read-Only •Input/Output
I2C
SpecializedRipple
Processing Units
Voltage
•••Proper
Device
Memory
USB Drivers
Peripheral
Noise
Compiler (EEPROM)
Set
Filtering •Transient
Architecture
SPI 8-bit, 16-bit, or 32-bit
Response
••Proper
MEMS
Timer devices
on the Chip
Decoupling
Ethernet Allowable Dissipation
••LineRS-232
Operating
RegulationVoltage
changes
2
Microprocessor Based System
CPU
External RAM, ROM, I/O
(No internal RAM, ROM, I/O ports in the CPU)
8051 Microcontroller 3
Microcontroller
A smaller computer on a CHIP
On-chip RAM, ROM, I/O Ports, Timer, Serial Controller…
Example: Motorola’s 6811, Intel’s 8051, Atmel 32
8051 Microcontroller 4
8051 - ARCHITECTURE
Microcontroller
▪ HMOS technology
▪ Single Power supply –5v
▪ Data memory – 128 bytes
▪ Programmable memory – 4096 bytes
▪ Software Flag – 128 user
▪ Addressable (16 address lines) – 64 K byte
▪ Bi-directional I/O lines – 32
▪ High speed Serial I / O
8051 family
Port 0
18
Crystal 39 - 32 AD0 – AD7
19
Port 2
21 - 28 A8 – A15
RST 9
31 Port 1
EA 1-8
User
PSEN 29
Port 3
ALE 30 10 - 17
Control
Ground 20
MEMORY MAP
Program Memory Internal RAM Data Memory
FFFF FF FFFF
SFR
External 80
7F
Data
RAM External
1000 00
0FFF
INT. EXT.
EA = 1 EA = 0
0000 0000
Internal Memory Map
Internal RAM
FF
Special
Function
Register
80
7F
Data
RAM
00
Internal Memory Map
Internal RAM
FF 7F
Special
Function
Register
80
7F
Data
RAM 20
1F
00 Bank 3
18
17
Bank 2
10
0F
Bank 1
08
07
00
Bank 0
Internal Memory Map
Internal RAM
FF 7F
Special 07 R7
Function
Register 06 R6
80
05 R5
7F
Data
04 R4
RAM 20
1F
00 Bank 3 03 R3
18
17 02 R2
Bank 2
10
0F
Bank 1 01 R1
08 Internal
07
00 R0 Pointers
00
Bank 0
Block Diagram
External interrupts
CPU
Bus Serial
4 I/O Ports
OSC Control Port
P0 P2 P1 P3 TxD RxD
Address / Data
D7 D6 D5 D4 D3 D2 D1 D0
PSW Register
D7 D6 D5 D4 D3 D2 D1 D0
Carry Parity
Au. Carry
User Flag1
User Flag 0 0 0 Bank 0 Over Flow
0 1 Bank 1
1 0 Bank 2
1 1 Bank 3
Stack Pointer
▪ SP is an 8 bit register
▪ May reside anywhere in on-chip RAM
▪ Normally initialized with 07H
▪ Actual location starts from 08H
▪ SP is incremented for Push, Call
▪ SP is decremented for Pop
Data Pointer
Timer 0, Timer 1
▪ Mode 0
8 bit counter
Divide by 32 pre-scalar
13 bit register
▪ Mode 1 – sixteen bits timer
▪ Mode 2 – 8 bit counter with auto-reload
▪ Mode 3 – Timer 1
To hold the count value
Two separate counter
Tmod Register
Timer - 1 Timer - 0
D7 D6 D5 D4 D3 D2 D1 D0
Gate M1 M0
0 0 8 bit counter
0 1 16 bit
C/T
1 for Counter 1 0 8 bit, auto reload
D7 D6 D5 D4 D3 D2 D1 D0
TF1 TR 1 TF 0 TR 0 IE1 IT 1 IE 0 IT 0
1 - ON by SW
0 - Off
4 modes
▪ Mode 0 – Data enters and exists through RxD
TxD outputs shift clock
8 bits, Baud rate 1/12 Frequency
▪ Mode 1 – 10 bits (data+ start, stop bit)
Data exists through TxD
Data received through RxD
Variable baud rate
▪ Mode 2 – 11 bits (data+ start, stop bit, parity bit)
Data exists through TxD
Data received through RxD
Baud rate is programmable
▪ Mode 3 – Similar to mode 2, Baud variable
Scon Register
D7 D6 D5 D4 D3 D2 D1 D0
Multi-processor
Comm. features Mode 2 / 3
9 bit
0 0 - mode 0 - fosc / 12
0 1 - mode 1 - 8 bit UART – variable baud
Receive Int. flag
1 0 - mode 2 - 9 bit UART – fosc / 32 or fosc / 64 set – HW
1 1 - mode 3 - 9 bit UART - variable Cleared - SW
Interrupt Enable Register
D7 D6 D5 D4 D3 D2 D1 D0
Int-1 Int-0
▪ By instruction
▪ Oscillator is stopped
▪ Content of RAM & SFR is held
▪ Exit only by Reset
▪ 5 modes
▪ Register – R0-R7, Acc, B, DPTR, Cy
▪ Direct – RAM, Special Function Reg.
▪ Register Indirect - @R0, @R1, SP
▪ Immediate
▪ Base register + Index register
@DPTR + Acc
@PC + Acc
Instruction Set
5 groups