First Design: Key Board
First Design: Key Board
R L S
First Design
Second Design
B
A
Key board
B
C D
Third Design
B
A
C
Contents:
Introduction
Block Diagram and Pin Description of the 8051
Registers
Memory mapping in 8051
Stack in the 8051
I/O Port Programming
Timer
Interrupt
Different aspects of a
microprocessor/controller
Microprocessors:
General-purpose microprocessor
CPU
GeneralPurpose
Microprocessor
Data Bus
RAM
ROM
I/O
Port
Address Bus
General-Purpose Microprocessor System
Timer
Serial
COM
Port
Microcontroller :
A smaller computer
On-chip RAM, ROM, I/O ports...
Example Motorolas 6811, Intels 8051, Zilogs Z8 and PIC 16X
CPU
I/O
Port
RAM ROM
Serial
Timer COM
Port
A single chip
Microcontroller
Block Diagram
External interrupts
Interrupt
Control
On-chip
ROM for
program
code
Timer/Counter
On-chip
RAM
Timer 1
Timer 0
CPU
OSC
Bus
Control
4 I/O Ports
P0 P1 P2 P3
Address/Data
Serial
Port
TxD RxD
Counter
Inputs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
8051
(8031)
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
Vcc
P0.0(AD0
P
) 0.1(AD1)
P0.2(AD2
P
) 0.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
P
) 2.4(A12
)P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
+
10 uF
31
30 pF
8.2 K
30 pF
11.0592 MHz
19
18
EA/VPP
X1
X2
9 RST
Port 0
P0.0
DS5000 P0.1
P0.2
8751
P0.3
P0.4
8951
P0.5
P0.6
P0.7
10 K
Registers
A
B
R0
DPTR
DPH
DPL
R1
R2
PC
PC
R3
R4
R5
R6
R7
Some 8-bitt Registers of
the 8051
2FH
Bit-Addressable RAM
Register Bank 3
Register Bank 2
Register Bank 1( Stack)
Register Bank 0
Timer:
:
Interrupt :
Hexadecimal
Binary
BCD
Hexadecimal Basis
Hexadecimal Digits:
1 2 3 4 5 6 7 8 9 A B C D E
F
A=10
B=11
C=12
D=13
E=14
)16
; MOV A, R4
; copy R2 to R6
; MOV R6,R2 is invalid !
SETB bit
CLR bit
; bit=1
; bit=0
SETB
SETB
SETB
SETB
SETB
; CY=1
;bit 0 from port 0 =1
;bit 7 from port 3 =1
;bit 2 from ACCUMULATOR =1
;set high D5 of RAM loc. 20h
C
P0.0
P3.7
ACC.2
05
Note:
DEC
INC
byte
byte
;byte=byte-1
;byte=byte+1
INC
DEC
DEC
R7
A
40H
; [40]=[40]-1
Jump if A=0
JNZ
Jump if A/=0
DJNZ
CJNE A,byte
Jump if A/=byte
CJNE reg,#data
Jump if byte/=#data
JC
Jump if CY=1
JNC
Jump if CY=0
JB
Jump if bit=1
JNB
Jump if bit=0
JBC
Call instruction
SETB P0.0
.
.
CALL UP
.
.
.
UP:CLR P0.0
.
.
RET