Micro Lec Note2
Micro Lec Note2
Microcontroller
8051 Basic Component
❑4K bytes internal ROM
❑128 bytes internal RAM
❑Four 8-bit I/O ports (P0 - P3).
❑Two 16-bit timers/counters
❑One serial interface
CPU
OSC Bus
4 I/O Ports Serial
Control
P0 P2 P1 P3 TXD RXD
Addr/Data
hsabaghianb @ kashanu.ac.ir Microprocessors 1-3
Other 8051 featurs
❑ only 1 On chip oscillator (external crystal)
❑ 6 interrupt sources (2 external , 3 internal, Reset)
❑ 64K external code (program) memory(only read)PSEN
❑ 64K external data memory(can be read and write) by
RD,WR
❑ Code memory is selectable by EA (internal or external)
❑ We may have External memory as data and code
❑Keyboard
❑Printer
❑video game player
❑MP3 music players
❑Embedded memories to keep configuration
information
❑Mobile phone units
❑Domestic (home) appliances
❑Data switches
❑Automotive controls
8952 8k 256 3 8 32 -
891051 1k 64 1 3 16 AC
892051 2k 128 2 6 16 AC
Foot Print
P1.1 2 39 P0.0(AD0)
P1.2 3 38 P0.1(AD1)
P1.3 4 37 P0.2(AD2)
P1.4 5 36 P0.3(AD3)
P1.5 6 35 P0.4(AD4)
P1.6 7 34 P0.5(AD5)
P1.7 8 33 P0.6(AD6)
RST 9
8051 32 P0.7(AD7)
(RXD)P3.0 10 (8031) 31 EA/VPP
(TXD)P3.1 11 30 ALE/PROG
(INT0)P3.2 12
(8751) 29 PSEN
(INT1)P3.3 13 (8951) 28 P2.7(A15)
(T0)P3.4 14 27 P2.6(A14)
(T1)P3.5 15 26 P2.5(A13)
(WR)P3.6 16 25 P2.4(A12)
(RD)P3.7 17 24 P2.3(A11)
XTAL2 18 23 P2.2(A10)
XTAL1 19 22 P2.1(A9)
GND 20 21 P2.0(A8)
TB1
Read pin
TB1
Read pin
TB1
Read pin
1 1 P1.X pin
Internal CPU bus D Q
P1.X
0 M1
Write to latch Clk Q
TB1
Read pin
3. Read pin=1 Read latch=0
Write to latch=1
TB1
Read pin
3. Read pin=1 Read latch=0
Write to latch=1
8051 IC
Vcc
10 K
P0.0
Port
DS5000 P0.1
P0.2
8751 P0.3
8951 P0.4 0
P0.5
P0.6
P0.7
❑ Vcc(pin 40):
❖Vcc provides supply voltage to the chip.
❖The voltage source is +5V.
❑ GND(pin 20):ground
❑ XTAL1 and XTAL2(pins 19,18):
❖These 2 pins provide external clock.
❖Way 1:using a quartz crystal oscillator
❖Way 2:using a TTL oscillator
❖Example 4-1 shows the relationship
between XTAL and the machine cycle.
C1
XTAL1
30pF
GND
N XTAL2
C
EXTERNAL
OSCILLATOR
SIGNAL XTAL1
GND
❑ Solution:
❑ RST(pin 9):reset
❖ input pin and active high(normally low).
➢The high pulse must be high at least 2
machine cycles.
❖ power-on reset.
➢Upon applying a high pulse to RST, the
microcontroller will reset and all values in
registers will be lost.
➢Reset values of some 8051 registers
❖ power-on reset circuit
Vcc
31
EA/VPP
X1
10 uF 30 pF
X2
RST
9
8.2 K
Figure 2-7
Multiplexing
the address
(low-byte)
and data
bus
Figure 2-8
Accessing
external
code
memory
Figure
2-11
Interface
to 1K
RAM
D0
D7
EA
P2.0 A8
P2.7 A15
8051 ROM
hsabaghianb @ kashanu.ac.ir Microprocessors 1-38
External data memory
WR WR
RD RD
PSEN
ALE 74LS373 CS
G
P0.0 A0
D
P0.7 A7
D0
D7
EA
P2.0 A8
P2.7 A15
8051 RAM
hsabaghianb @ kashanu.ac.ir Microprocessors 1-39
Overlapping External Code
and Data Spaces
D0
D7
EA
P2.0 A8
P2.7 A15
8051 RAM
hsabaghianb @ kashanu.ac.ir Microprocessors 1-41
Overlapping External Code
and Data Spaces
❑Allows the RAM to be
❖ written as data memory, and
❖ read as data memory as well as code memory.
Bank 1
08
07 R7
06 R6
05 R5
04 R4
03 R3 Bank 0
02 R2
01 R1
00 R0
❑DATA registers
❑CONTROL registers
❖Timers
❖Serial ports
❖Interrupt system Addresses 80h – FFh
❖Analog to Digital converter
❖Digital to Analog converter Direct Addressing used
❖Etc. to access SPRs
Figure 2-6
Summary
of the 8051
on-chip
data
memory
(RAM)
Figure 2-6
Summary
of the 8051
on-chip
data
memory
(Special
Function
Registers)
Used in assembler
instructions
B
R0
DPTR DPH DPL
R1
R2 PC PC
R3
R6
R7