Professional Documents
Culture Documents
8051 Microcontroller
(Hardware Specification)
Lec note 4
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-1
Microcontroller (uC)
u-Computer on a single chip of silicon
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-2
uP vs. uC
A uP
single-chip contained only CPU bus is available RAM capacity, num of port is selectable RAM is larger than ROM (usually)
A uC
single-chip contained CPU, RAM, ROM, Prepherals, I/O port Communicate by port internal hardware is fixed ROM is larger than RAM (usually)
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-3
uC base system
Small power consumption Single chip, small board Implementation is easy Low cost Can be used as Reconfigurable Hardware uC can reprogram on the fly(ISP)
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-4
uP vs. uC Applications
uCs are suitable to control of I/O devices in designs requiring a minimum component
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-5
uCs
Many uCs are existing right now. We may widely divide it with
how it is designed (RISC/CISC architecture)
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-6
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-7
Block Diagram
External Interrupts
Interrupt Control
4k ROM
Timer 1 Timer 2
CPU
OSC
Bus Control
4 I/O Ports
Serial
P0 P2 P1 Addr/Data
hsabaghianb @ kashanu.ac.ir
P3
TXD RXD
Microprocessors 4-8
RD,WR
Code memory is selectable by EA (internal or external) We may have External memory as data and code
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-9
Embedded System
(8051 Application)
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-10
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
89xx
Example (AT89C51,AT89LV51,AT89S51)
AT= ATMEL(Manufacture) C = CMOS technology LV= Low Power(3.0v)
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-13
ROM
4k
RAM
128
Timer
2
Source 6
Int
IO pin
32
Other
-
8952
8953 8955
8k
12k 20k
256
256 256
3
3 3
8
9 8
32
32 32
WD WD
898252
891051 892051
8k
1k 2k
256
64 128
3
1 2
9
3 6
32
16 16
ISP
AC AC
WD: Watch Dog Timer AC: Analog Comparator ISP: In System Programable
hsabaghianb @ kashanu.ac.ir Microprocessors 4-14
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-15
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-16
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)
Microprocessors 4-17
hsabaghianb @ kashanu.ac.ir
Port 2 P2P2.0P2.7 8-bit R/W - General Purpose I/O high byte address for external memory
Port 3 P3P3.0P3.7 General Purpose I/O Timers(T0,T1) ext. int (INT0, INT1) Serial (TXD, RXD)- RD,WR
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-19
Read latch
B2
P1.X
Clk Q
P1.X pin M1
B1 Read pin
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-20
2 Tri-state buffer
B1: controlled by Read pin
Read pin1really read the data present at the pin
Read latch B2
1 0
M1
P1.X
Clk Q
output 1
B1 Read pin
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-22
Read latch B2
0 1
M1
P1.X
Clk Q
output 0
B1 Read pin
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-23
Read latch 1. write a 1 to the pin MOV P1,#0FFH Internal CPU bus B2
Vcc
Internal Pull-Up D Q
P1.X 1 1 P1.X pin
Write to latch
Clk
M1
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-24
Read latch 1. write a 1 to the pin MOV P1,#0FFH Internal CPU bus B2
Vcc
2. MOV A,P1
Internal Pull-Up D Q
P1.X 1 0
external pin=Low
P1.X pin
Write to latch
Clk
M1
B1 Read pin 3. Read pin=1 Read latch=0 8051 IC hsabaghianb @ kashanu.ac.ir Microprocessors 4-25
Read-Change-Write Operation
Example: Complement Value of a pin (CPL P1.5)
Read latch Vcc B2
Internal Pull-Up D Q
P1.X M1 P1.X pin
Clk
B1 Read pin
10 K
8751 8951
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-27
Port 0
Port3 Alternate IO
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-28
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-29
Important Pins
PSEN (out):
Program Store Enable
ALE (out): Address Latch Enable to latch address outputs at Port0 and Port2 EA (in): External Access Enable
to access external program memory 0 to 4K (active low)
RXD,TXD: UART pins for serial I/O on Port 3 Vccpin 40: +5V (3~5V for 89LV51) GNDpin 20: ground XTAL1 , XTAL2pins 19,18
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-31
N C
EXTERNAL OSCILLATOR SIGNAL
XTAL2
XTAL1
GND
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-32
Machine cycle
Machine Cycle Freq.=1/12 XTAL Find the machine cycle for
(a) XTAL = 11.0592 MHz (b) XTAL = 16 MHz.
Solution:
(a) 11.0592 MHz / 12 = 921.6 kHz; machine cycle = 1 / 921.6 kHz = 1.085 s (b) 16 MHz / 12 = 1.333 MHz; machine cycle = 1 / 1.333 MHz = 0.75 s
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-33
Power-On Reset
Vcc
31 10 uF 30 pF
EA/VPP X1
X2 RST 9
10 K
ACC
B PSW SP
00
00 00 07
DPTR
RAM are all zero
hsabaghianb @ kashanu.ac.ir
0000
Microprocessors 4-35
Types of Memory
FFFFh
External
DATA
8051 Chip
Internal RAM
SFRs
Internal code Memory
(EEPROM)
FFFFh
External
CODE
ROM
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-36
Types of Memory
External Code Memory (64k) External RAM Data Memory (64k) Internal Code Memory
4k,8k,12k,20k ROM, EPROM, EEPROM First 128 bytes: 00h to 1Fh 20h to 2Fh 30 to 7Fh Next 128 bytes: 80h to FFh
Internal RAM
Register Banks Bit Addressable RAM General Purpose RAM Special Function Registers
Microprocessors 4-37
hsabaghianb @ kashanu.ac.ir
External Memory
/EApin 31external access
/EA=0 indicates that code is stored externally. /PSEN ALE are used for external ROM. For 8051 internal code, /EA pin is connected to Vcc. / means active low.
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-38
External Memory
ALEpin 30: address latch enable
It is an output pin and is active high
8051 port 0 provides both address and data The ALE pin is used for de-multiplexing the address and data by connecting to the G pin of the 74LS373 latch.
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-39
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-40
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-41
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-42
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-43
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-44
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-45
74LS373
CS A0 A7
D0
EA D7
P2.0
P2.7
A8
A15
8051
hsabaghianb @ kashanu.ac.ir
RAM
Microprocessors 4-46
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-48
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-49
Bank 3
18 17
Bank 2
10 0F
Bank 1
08 07 06 05 04 03 02 01 00 R7 R6 R5 R4 R3 R2 R1 R0
Bank 0
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-50
20h 2Fh (16 locations 8-bits = 128 bits) Bit addressing: mov C, 1Ah or mov C, 23h.2
2C
2B 2A 29 28 27 26 25 24 23 22 21 20
0F
07 06 05 04 03 02 01 1A 10
08
00
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-51
DATA registers CONTROL registers Timers Serial ports Interrupt system Analog to Digital converter Digital to Analog converter Etc.
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-52
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-53
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-54
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-55
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-56
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-57
Registers
A B R0 R1 R2 R3 R4 R5 R6 R7 PC PC
DPTR
DPH
DPL
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-58
hsabaghianb @ kashanu.ac.ir
Microprocessors 4-59