Professional Documents
Culture Documents
Microprocessors
& Microcontrollers
Atul P. Godse
M.S. Software Systems (BITS Pilani)
B.E. Industrial Electronics
Formerly Lecturer in Department of Electronics Engg.
Vishwakarma Institute of Technology,
Pune.
® ®
TECHNICAL
PUBLICATIONS
SINCE 1993 An Up-Thrust for Knowledge
(i)
Microprocessors & Microcontrollers
Subject Code : EC8691
Published by :
® ®
Amit Residency, Office No.1, 412, Shaniwar Peth,
TECHNICAL Pune - 411030, M.S. INDIA, Ph.: +91-020-24495496/97
PUBLICATIONS
SINCE 1993 An Up-Thrust for Knowledge Email : sales@technicalpublications.org Website : www.technicalpublications.org
Printer :
Yogiraj Printers & Binders
Sr.No. 10/1A,
Ghule Industrial Estate, Nanded Village Road,
Tal. - Haveli, Dist. - Pune - 411041.
ISBN 978-93-332-0231-2
9 789333 202312 AU 17
TON TOFF
T
modes :
SP
15 8 7 0
AX AH AL CS BP
BX BH BL DS SI
CX CH CL ES DI
DX DH DL SS F IP
(a) General purpose registers (b) Segment registers (c) Flag register (d) Pointer and
index registers
Address
FFFFFH
Extra segment 64 K
ES
Stack segment 64 K
SS 1 Mbyte
physical
memory
Data segment 64 K
DS
Code segment 64 K
CS
00000H
Memory
interface
BIU C-bus
C-Bus
6
5 Instruction
B-bus 4 stream
3 byte
ES
2 queue
CS
SS 1
DS
IP
Control
system
EU A-bus
AX AH AL
BX BH BL
Arithmetic
CX CH CL logic unit
DX DH DL
SP
BP
SI Operands
DI Flags
Time required for execution of two instructions without pipelining
Time
saved
Sequential F1 D1 E1 F2 D2 E2
phases
BIU F1 F2 F3
Overlapping
phases
EU D1 E1 D2 E2 D3 E3
BIT 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
U U U U OF DF IF TF SF ZF U AF U PF U CF
64 K
64 K
64 K
64 K
00000H
Physical memory
Physical addresses
(a) (b)
SP = 8434H
2000 0 H DS
+
002 0 H BX
Physical Address 2 0 0 2 0 H
001 0 H BP
+
004 0 H SI
Effective Address 005 0 H
3000 0 H SS
+
005 0 H EA
Physical Address 3 0 0 5 0 H
1000 0 H CS
+
002 0 H BX
Physical Address 1 0 0 2 0 H
ES 7 0 0 0 0 H
SI + 1 0 0 0 H
7 1 0 0 0 H
SS 9 0 0 0 0 H
SP + 0 0 0 0 H
9 0 0 0 0 H
DS 8 0 0 0 0 H
DI + 2 0 0 0 H
8 2 0 0 0 H
DS 8 0 0 0 0 H ES 7 0 0 0 0 H
SI + 1 0 0 0 H DI + 2 0 0 0 H
8 1 0 0 0 H 7 2 0 0 0 H
DS 8 0 0 0 0 H
DI + 2 0 0 0 H
8 2 0 0 0 H
DS 8 0 0 0 0 H
EA + 2 0 8 D H
8 2 0 8 D H
DS 8 0 0 0 0 H
EA + 1 0 2 D H
8 1 0 2 D H
ES B 0 0 0 0 H
+ EA 2 0 5 D H
B 2 0 5 D H
SS A 0 0 0 0 H
+ SP 0 0 0 0 H
A 0 0 0 0 H
DS 6 0 0 0 0 H
+ EA 2 4 2 D H
6 2 4 2 D H
DS 6 0 0 0 0 H ES B 0 0 0 0 H
+ SI 2 0 0 0 H + DI 3 0 0 0 H
6 2 0 0 0 H B 3 0 0 0 H
DS 6 0 0 0 0 H
+ SI 2 0 0 0 H
6 2 0 0 0 H
DS 6 0 0 0 0 H
+ EA 3 0 8 D H
6 3 0 8 D H
DS 6 0 0 0 0 H
+ EA 2 0 0 2 H
6 2 0 0 2 H
[10H]
124B 0 H
+ 341 C H
158C C H
1085 0 H
+ 453 7 H
14D8 7 H
( 341B )H
(123A )H
OS 123A0 implied zero
Offset 341B
157BB physical address
Memory stack segment
30036H
30035H
CX
CH CL 30034H
20 30 30 30033H
20 30032H
30031H
30030H
SP 0034
30000H
30000
SS 3000 +
SS 10H
30045H
30044H
40 30043H
40 50 50 30042H
CH CL
30041H
CX
30040H
SP 0042
30000H
30000
SS 3000 +
SS 10H
CX 0
A B
X X X X X X X X Unknown 8-bit binary number
1 1 1 1 0 0 0 0 Masking pattern
X X X X 0 0 0 0 Result
Masked bits
X X X X X X X X Unknown 8-bit binary number
+ 1 1 1 1 0 0 0 0 Setting pattern
1 1 1 1 X X X X Result
Set bits
Y A BA B
X X X X X X X X Unknown 8-bit binary number
X X X X X X X X Result
Inverted bits
X X X X X X X X Unknown 8-bit binary number
0 0 0 0 0 0 0 X Result
Tested bit
2n
SHL 0
CY
SAL 0
CY
SHR 0
CY
SAR
0 1 0 1 1 0 1 1 1 0
After execution 1 0 1 1 0 1 1 1 0
B7 B6 B5 B4 B3 B2 B1 B0 CY
0 1 0 1 0 1 0 0 1 0
After execution 0 1 0 1 0 1 0 0 1
B7 B6 B5 B4 B3 B2 B1 B0 CY
1 0 1 0 1 0 0 1 0
1 1 0 1 0 1 0 0 1
CY Target register or memory
RCL
( Rotate left through carry )
CY
ROL
( Rotate left )
CY
RCR
( Rotate right through carry )
CY
ROR
( Rotate right )
CY B7 B6 B5 B4 B3 B2 B1 B0
1 0 1 0 1 0 1 1 1
0 1 0 1 0 1 1 1 0
B7 B6 B5 B4 B3 B2 B1 B0 CY
1 0 1 0 0 0 1 1 0
1 1 0 1 0 0 0 1 1
CY B7 B6 B5 B4 B3 B2 B1 B0
0 1 0 1 0 1 1 0 1
1 0 1 0 1 1 0 1 0
B7 B6 B5 B4 B3 B2 B1 B0 CY
1 0 0 1 1 0 1 0 1
1 1 0 0 1 1 0 1 0
opcode
short EB Disp
opcode
opcode
IP IP CS CS
far EA High High
Low Low
Mnemonic Source operand
Define problem
Program
Develop algorithm File extensions
development
time
Create assembly language
program using any text editor ASM
Assemble
if
Assemble time YES
assembly
error
NO
Object code module in binary OBJ
LST
Link
Link time
Linked modules EXE
MAP
NO External YES
system?
Load debugger Load emulator
Load
time
Load program Load program
Errors NO NO Errors
? ?
YES YES
Use debugger to Use debugger to
find errors Stop find errors
[
Assembly language
Source program text written
module in any text editor [
Make
Error corrections
messages
Object
Other object module
modules
Linked
modules
(Load module)
CPU
Both data
segments have
same starting
address
Code for
source
module 1
Code
segment
Code for
source
module 2
(a)
My_stack
segment
150
words
combined
stack
Top_of_stack
(b)
End of stack segment 4FFFFH
SP = 9F20H
40003H 40003H
40002H 40002H
40001H 40001H
SS 4000H Start of stack segment SS 4000H Start of stack segment
40000H 40000H
BX DX BX 4455H DX 1234H
40003H 40003H
40002H 40002H
40001H 40001H
SS 4000H Start of stack segment SS 4000H Start of stack segment
40000H 40000H
RETURN TO
MAIN PROGRAM
CALL
RECURSIVE CALL CALL CALL
NEXT MAINLINE
INSTRUCTION
IF N
DECREMENT N
CALL RECURSIVE
ELSE
RETURN
IF XX (condition)
ELSE (optional) Conditional Block
ENDIF (end of IF)
4 (Count 1) (2 16) (2 4)
MOV CX, Count Loop Last loop
1
10 MHz
50 ms
0.1 s
Number of required clock cycles 4 (2 4)
Execution time for one loop
500 000 4 6
(16 2)
4 (count 1) ( 2 16) (2 4) ]
MOV CX, Count Loop Last loop
INTERRUPT
SERVICE
PROCEDURE
MAINLINE PUSH FLAGS
PROGRAM CLEAR IF PUSH REGISTERS
CLEAR TF
PUSH CS
PUSH IP
FETCH ISR ADDRESS
POP IP
POP CS POP REGISTERS
POP FLAGS IRET
ADDRESS
3FFH
TYPE 255 POINTER :
(AVAILABLE)
3FCH
AVAILABLE INTERRUPT
POINTERS (224)
TYPE 33 POINTER :
(AVAILABLE)
084H
TYPE 32 POINTER :
080H (AVAILABLE)
07FH
TYPE 31 POINTER :
(RESERVED)
RESERVED INTERRUPT
POINTERS (27)
TYPE 5 POINTER :
(RESERVED)
014H
TYPE 4 POINTER :
OVERFLOW
010H
TYPE 3 POINTER :
1-BYTE INT INSTRUCTION
00CH
DEDICATED INTERRUPT TYPE 2 POINTER :
POINTERS (5) NON-MASKABLE
008H
TYPE 1 POINTER :
SINGLE-STEP
004H
TYPE 0 POINTER : CS BASE ADDRESS
DIVIDE ERROR IP OFFSET
000H
16 BITS
11 4 44 10
T1 T2 T3 T4 T1 T1 T1 T2 T3 T4
ALE
LOCK
INTA
FLOAT
MAIN PROGRAM
NMI
DIV
DIVIDE ERROR
IF = 0 TF = 0
EXECUTE NMI
EXECUTE DIVIDE
ERROR ROUTINE
(Max (Min
mode) mode)
GND 1 40 VCC GND 1 40 VCC
AD14 2 39 AD15 A14 2 39 A15
AD13 3 38 A16/S3 A13 3 38 A16/S3
AD12 4 37 A17/S4 A12 4 37 A17/S4
AD11 5 36 A18/S5 A11 5 36 A18/S5
AD10 6 35 A19/S6 A10 6 35 A19/S6
AD9 7 34 BHE/S7 A9 7 34 SS0 (HIGH)
AD8 8 33 MN/MX A8 8 33 MN/MX
(Min (Max
AD7 9 32 RD mode) AD7 9 32 RD mode)
AD6 10 8086 31 RQ/GT0 (HOLD) AD6 10 8088 31 HOLD (RQ/GT0)
CPU CPU
AD5 11 30 RQ/GT1 (HLDA) AD5 11 30 HLDA (RQ/GT1)
AD4 12 29 LOCK (WR) AD4 12 29 WR (LOCK)
AD3 13 28 S2 (M/IO) AD3 13 28 IO/M S2
AD2 14 27 S1 (DT/R) AD2 14 27 DT/R S1
AD1 15 26 S0 (DEN) AD1 15 26 DEN S0
AD0 16 25 QS0 (ALE) AD0 16 25 ALE (QS0)
NMI 17 24 QS1 (INTA) NMI 17 24 INTA (QS1)
RQ GTO DEN
IO
BHE A0
CS CS
Bank 1 Bank 0
(512 bytes) (512 bytes)
Address
bus A1 A19 A1 A19
003FFH 003FEH
003FDH 003FCH
0007FH 0007EH
0007DH 0007CH
Reserved Interrupt
vector
table
00015H 00014H
128 bytes 00013H 00012H
00011H 00010H
Dedicated
00003H 00002H
00001H 00000H
Odd Bank Even Bank
7 0
FFFFH
FFFEH
00FFH 64 K
00FEH I/O space
Reserved
00F8H
Page 0
00F7H
0001H
0000H
+VCC
+VCC
MN/MX
CLK
R 8284A ALE STB
Clock READY
BHE BHE
generator 8282
RESET
Address Address
RES A19-A16 latch bus
C RDY
(3)
AD15-AD0 OE
WAIT
STATE
8086 CPU
GENERATOR
8286 Data
Transceiver bus
(2)
DEN OE
DT/R T
STB OE STB OE
AD0 A0 B0
AD1 A1 B1
AD2 A2 B2
AD3 A3 8 B3 Data Bus
AD4 A4 2 B4
AD5 A5 B5
AD6 A6 8 B6
AD7 A7 6 B7
DEN OE
DT/R T
8086
AD8 A0 B0
AD9 A1 B1
AD10 A2 B2
AD11 A3 8 B3 Data Bus
AD12 A4 2 B4
AD13 A5 B5
AD14 A6 8 B6
AD15 A7 6 B7
OE
T
RES D
Q RESET
CLK
X1
XTAL
X2 Oscillator
OSC
F/C
+3 +2 PCLK
SYNC SYNC
EFI
CSYNC
RDY1
AEN1 CLK
ASYNC
X1 X2
RESET RESET
F/ C
AEN1
AEN2 READY READY
CSYNC
+5 V
8284 8086
Clock generator
10 K
RES
10 F
PCLK
RDY1 RDY2
VCC
Clock
generator
RES 8284
Rdy VCC
MN/MX
Wait
state M/IO M/IO
generator CLK
INTA INTA
Ready
Reset RD RD
WR WR
DT/R T D0
DEN OE D15
Y7 A0 Y6 Y0 A0 Y1
Transceivers
(2) O0
Y0 O0
Addr Addr OE D8-D15 Addr CS OE D0-D7 Addr CS OE WRD8-D15 Addr CS OE WR D0-D7 Addr CS RD WRD0-D15 CS
Y1 O1
Data Data Data Data Data
Decoder VCC Decoder
EPROM (ODD) EPROM (EVEN) RAM (ODD) RAM (EVEN) I/O
Y6 O6
M/IO EN EN Y7 EN EN O7
BHE A 19 A 18 A 17 A 16 A 15 A 14 A 13 A 12 A 11 A 10 A 9 A 8 A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0
VCC
MN/MX
74LS373(2)
L
AD15 A A0
AD0 T
A15
CLK C
ALE H
D0
8086 VCC D15
74LS138
D G1 MEMR
E
RD A C MEMW
O
WR B D IOR
E
M/IO C R
IOW
G1 G2
CLK Reset Ready A16
Y1
BHE G2 GND
74LS373 74LS138
Fig. 6.4.7 Interfacing 128 K RAM and 2K ROM with 8086 in minimum mode
VCC LOCAL BUSES
STB
GND OE 1 MEGABYTE
AD0-AD15 ADDRESS BUS
ADDR/DATA 8282
A16-A19 LATCH
(2 OR 3)
BHE
T
OE 16-BIT
8286 DATA BUS
TRANSCEIVER
(2)
Latches
STB 8282s (3)
If there is no
8259A, this is
Clock an inverter
8284A
OE Transceiver
8286 (2)
T
CLK ALE
CEN DEN
+5 V
Control Control
AEN logic signal DT/R
generator
8086/ IOB MCE/PDEN
8088
BUS MRDC
controller
8288 MWTC
Command Control
IQRC bus
S0 signal
S0 generator IOWC
S1 Status
S1 INTA
S2
decoder
S2
INTA
Priority interrupt
controller 8259A
VCC
INTA INTERRUPT
LOCK N.C. ALE
WAIT ACKNOWLEDGE
STATE
GENERATOR
STB
GND OE 1 MEGABYTE
AD0-AD15 ADDRESS BUS
ADDR/DATA 8282
A16-A19 LATCH
(2 OR 3)
BHE
T
OE 16-BIT
8286 DATA BUS
TRANSCEIVER Y7 A0 Y6 Y0 A0 Y1
(2)
Y0
Y1 Y2
Addr Decoder
Y6 OE D8-D15 Addr CS OE D0-D7 Addr CS OE WRD8-D15 Addr CS OE WR D0-D7 Addr CS RD WRD0-D15 CS
EN Y7
Data Data Data Data Data
EPROM (ODD) EPROM (EVEN) RAM (ODD) RAM (EVEN) I/O
RQ GT
One Bus Cycle
T1 T2 T3 T4
CLK
Address, BHE OUT
A19/S6-A16/S3
Status OUT
and BHE/S7
TAVDV
AD15-AD0 Data IN
Address OUT
ALE
RD
TRLDV
DT/R
DEN
CLK
Address, BHE OUT
A19/S6-A16/S3
Status OUT
and BHE/S7
TDVWH
ALE
TWLWH
WR
DT/R
DEN
CLK
HOLD
HLDA
AD15-AD0 Requesting
8086 master 8086
A19/S6, A16/S3
BHE/S7, M/IO
RD, WR, DT/R, DEN
One Bus Cycle
T1 T2 T3 T4
CLK
S2-S0 S2-S0
S2-S0 Inactive
BHE, A19-A16
Address/status Float
S7-S3
AND BHE/S7
Data IN D15-D0
Address/data A15-A0
(AD15-AD0)
TAVDV
* ALE
TRLDV
* MRDC
or IORC
* DT/R
* DEN
CLK
S2-S0
S2-S0
S2-S0 Inactive
BHE, A19-A16
Address/status Float
S7-S3
AND BHE/S7
* ALE
TWLWHA
* AMWC
or AIOWC
* MWTC
or IOWC TWLWH
* DEN
* 8288 bus controller
outputs
CLK
RQ/GT
DEN
R
MX
MN / MX
MX MX
MX
BHE A0
BHE A0
QS1 QS 0
QS 1 QS 0
DEN
DEN
DT R
AMWC
AIOWC
D 0 - D7
Input
port
Data bus (Tri-state buffer) Data from input
device
(Keyboard)
Enable
D 0 - D7
Output
device
Data bus (Latch)
To output device
(Display)
CLK
Start I/O
routine
Is
Yes Call the I/O port A
service request
bit set service routine
?
No
Is
Yes Call the I/O port B
service request
bit set service routine
?
No
Is
Yes Call the I/O port C
service request
bit set service routine
?
No
End
28
( 2 16 )
Buffer
or To
A0 Data I/O
Latch
A1 bus device
Decoder
A2
OE
A3
A4 G1
A5 G2 M/IO IORC/IOWC
A6
A7 G RD/WR
Y0
74LS138
+5 V
R R R R R R R R = 10 K
74LS244
S0 I0 O0
S1 I1 O1
S2 I2 O2
S3 I3 O3
Tri-state Lower byte
DIP S4 I4 buffer O4 Data bus(D0-D7)
switches of 8086
S5 I5 O5
S6 I6 O6
S7 I7 O7
OE
A0 A
A1 D
B
A2 e
C
A3 c
A4 G1 o
A5 G2 d M/IO
e IOR
A6
A7 G r RD
Y0
74LS138
VCC = +5 V
G VCC
A2 A (MSB) Y0 PORT (E8)
A1 B Y1 PORT (E9)
A0 C (LSB) Y2 PORT (EA)
Y3 PORT (EB)
A7 74138
A6 Y4 PORT (EC)
G2
A5 Y5 PORT (ED)
A3 Y6 PORT (EE)
A4 G1 Y7 PORT (EF)
GND
+5 V
R R R R R R R R = 10 K
74LS244
S0 I0 O0
S1 I1 O1
S2 I2 O2
S3 I3 O3
Tri-state Lower byte
DIP S4 I4 buffer O4 Data bus(D0-D7)
switches of 8086
S5 I5 O5
S6 I6 O6
S7 I7 O7
OE
+5 V
R R R R R R R R = 10 K
74LS244
S8 I0 O0
S9 I1 O1
S10 I2 O2
S11 I3 O3
Tri-state Higher byte
DIP S12 I4 buffer O4 Data bus(D15-D8)
switches of 8086
S13 I5 O5
S14 I6 O6
S15 I7 O7
OE
A0 A
A1 D
B
A2 e
C
A3 c
A4 G1 o
A5 G2 d M/IO
e IORC
A6
A7 G r RD
Y0
74LS138
+5 V
L0 L7
330
A0 A O0
D Lower Byte L
A1 B A
E Data bus (D7-D0)
A2 Y2 T
C C of 8086
C
A3 O
A4 G1 H
D O7
A5 G2 E M/IO LE
A6 R 330
A7 WR
G IOWC
A7 A6 A5 A4 A3 A2 A1 A0
1 0 0 0 0 0 1 0 = 82H
+5 V +5 V
L0 L7 L8 L15
330
A0 A O0
Lower byte L
A1 D
B Data bus (D7-D0) A
E
A2 T
C C of 8086
Y1 C
A3 O
A4 G1 H
D
A5 E LE O7
G2
A6 R 330
A7 G
330
O0
Higher byte L
Data bus (D8-D15) A
T
of 8086 C
H
LE O7
M/IO
WR 330
IOWC
74LS244 R R 10 K
D0
B
Lower byte U S0
Data bus of 8086 F
F
E
RD R D7
IORC
S7
OE
+5 V
M/IO
IOWC Y0
L0 L7
WR
A0 A 74LS373
A1 D
B E Y0
A2 330
C C
L O0
A3 O Y2 A
A4 G1 D
T
A5 G2
E
C
A6 R
H
A7 G O7
330
LE
Start
Is No
S1 = 0
?
Yes
+5 V
74LS244 R R 10 K
D0
B
U
Lower Byte F S0
Data bus of 8086 F
E
R
RD IORC D7
S7
OE
+5 V
M/IO
IOWC Y0
WR L0 L7
A0 A 74LS373
A1 D
B E Y0
A3 A2 330
C C L O0
A4 O Y2 A
G1 T
A5 D C
A6 A7 G E H
R
G2 O7
330
A8 74LS138 LE
A9
A10
A11
A12
A13
A14
A15
+5 V
R R 10 K
74LS244
D0
B
U
Lower byte F S0
Data bus of 8086 F
E
R
RD D7
MRDC
S7
OE
+5 V
M/IO
MWTC Y0
WR L0 L7
A0 A 74LS373
A1 D
B E Y0
A3 A2 330
C C L O0
A4 O Y2 A
G1 T
A5 D C
A6 A7 G E H
R
G2 O7
A8 330
A9 74LS138 LE
A10
A11
A12
A13
A14
A15
A16
A17
A18
A19
BHE A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
VCC
MN/MX
74LS373
L
AD15 A A0
AD0 T
A15
C
ALE H
D0
D15
VCC
G1 MEMR
D
RD A E MEMW
C
WR B O
D
IOR
M/IO C E
R IOW
G1 G2
CLK Reset Ready
74LS138
D0-D7 RD WR A1 D8-D15 RD WR A1 D0-D7 RD WR A1 D8-D15 RD WR A1 D0-D7 RD WR A1
BHE LATCH
ALE
A 15 A 14 A 13 A 12 A 11 A 10 A 9 A 8 A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0
Y0
A4 A0
Y1
A5 A1 0010H
Y2
A6 A2 3:8 0020H
Y3
Decoder 0030H
A0 Y4
74LS138 0040H
Y5
E3
A3 Y6
A7 E1 Y7
A15 E2
M IO M IO
IO M IO M
Interrupt request
I/O
CPU System
Interrupt acknowledgement
Start
Initialize counter
Initialize source pointer
Get byte
Send byte
No
Last byte ?
Yes
Stop
CPU DMA
Start
Send addresses of
source and destination Request bus
and number of bytes
to transfer
No
Bus free !
Yes
Release bus
Total data
bytes No
transferred
Yes
Notify CPU of
Acknowledge
completion
Stop
Data transmission
Serial Parallel
t1 t2
Process 2
Process 2
Time
(b) Multi-programming approach
Memory
8086/8088
Processor
Bus
Bus Bus
Clock control System bus
Request Grant
logic
Coprocessor
or
Independent I/O
processor Devices
8086/8088
Set up a task
message
Independent processor
Wake up
independent Command Wait for
processor request
(Start Channel) Channel
Attention
Fetch task
message
(Read task)
Execute
its own
program sequence
Execute
assigned task
Status
or
Wait for IRQ Inform CPU
ready or
of completion
interrupt request
Next task
System System
memory I/O devices
System bus
Clock Clock
Bus grant
Bus request Bus
Control
Bus busy Logic
System bus
Bus
Control
Logic
Bus request
Bus busy
System bus
Bus grant 1
Bus request 1
Bus grant 2
Bus request 2 Bus
Control
Logic
Bus grant N
Bus request N
Bus busy
VSS 1 40 VCC
A14/D14 2 39 A15/D15
A13/D13 3 38 A16/S3
A12/D12 4 37 A17/S4
A11/D11 5 36 A18/S5
A10/D10 6 35 A19/S6
A9/D9 7 34 BHE/S7
A8/D8 8 33 RQ/GT1
A7/D7 9 32 INT
A6/D6 10 8087 31 RQ/GT0
A5/D5 11 NDP 30 NC
A4/D4 12 29 NC
A3/D3 13 28 S2
A2/D2 14 27 S1
A1/D1 15 26 S0
A0/D0 16 25 QS0
NC 17 24 QS1
NC 18 23 BUSY
CLK 19 22 READY
VSS 20 21 RESET
NC = NO CONNECT
INT INTR MN/MX
8259A
(Programmable
8086
interrupt S2-S0 (Processor status)
controller) AD15-AD0
RQ/GT A19-A16
IRn
TEST QS1-QS0 BHE 8086/8088
Bus Interface
Components
Multi -Master
(Bus controller, System Bus
Busy Queue status latches and
transreceivers)
Interrupt Bus
Ready, Clock request request/grant
and Reset
8284A
Clock
generator
Coprocessor
(such as 8087)
Ready Reset
8086/8088 Coprocessor
Is Is
Yes MSBs of MSBs of No
Treat instruction Treat instruction
as NOP code byte code byte as NOP
= 11011 = 11011
?
Deactivate the
Execute
host's TEST pin and
the 8086
execute the specified
instructions
operation
Activate the
Is TEST pin
No WAIT
instruction 8
08
? or8
86
80
he
upt
ke
Yes Wa
Check
Yes whether No
TEST pin is
activated
Control Unit Numeric Execution Unit
15 0
80 bits
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Exception flag
B C3 ST C2 C1 C0 IR PE UE OE ZE DE IE (1=exception has occurred)
Invalid operation
Denormalized operand
Zerodivide
Overflow
Underflow
Precision
(reserved)
Interrupt request
Condition code ST values :
000 = register 0 is stack top
Stack top pointer 001 = register 1 is stack top
Conditional code
Busy 111 = register 7 is stack top
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
IC RC PC IEM PM UM OM ZM DM IM EXCEPTION MASKS
(1=EXCEPTION IS MASKED)
INVALID OPERATION
DENORMALIZED OPERAND
ZERODIVIDE
OVERFLOW
UNDERFLOW
PRECISION
(RESERVED)
(1)
INTERRUPT-ENABLE MASK
PRECISION CONTROL(2)
ROUNDING CONTROL(3)
INFINITY CONTROL(4)
(RESERVED)
(1) Interrupt - Enable mask (3) Rounding control
0 = Interrupts enable 00 = Round to nearest or Even
1 = Interrupts disabled (Masked) 01 = Round down (toward %)
(2) Precision control 10 = Round up (toward %)
00 = 24 bits 11 = Chop (Truncate toward Zero)
01 = (reserved) (4) Infinity control
10 = 53 bits 0 = Projective
11 = 64 bits 1 = Affine
DEFAULT AFTER FINITE
Approximate
Data type Bytes Range (decimal) Format
Table (a) Table (c)
Order C3 C0 (ST) C3 C2 C1 C0
(ST) > (SRC) 0 0 + Unnormal 0 0 0 0
(ST) < (SRC) 0 1 + NAN 0 0 0 1
(ST) = (SRC) 1 0 – Unnormal 0 0 1 0
Not comparable 1 1 – NAN 0 0 1 1
+ Normal 0 1 0 0
+ 0 1 0 1
– Normal 0 1 1 0
– 0 1 1 1
+0 1 0 0 0
Empty 1 0 0 1
Table (b) –0 1 0 1 0
Order C3 C0 Empty 1 0 1 1
(ST) > 0 . 0 0 0 + Denormal 1 1 0 0
(ST) < 0 . 0 0 1 Empty 1 1 0 1
(ST) = 0 . 0 1 0 – Denormal 1 1 1 0
Not comparable 1 1 Empty 1 1 1 1
4
4
2x 1
Programmable Memory
I/O Peripheral Data Data and
Devices Interface (8255) instructions
Command and Data
status
CRT
CPU Controller
Command and (8275)
status
Handshaking
Serial I/O USART
Data
Devices (8251)
DMA
Command and Command and controller
status status
Data
CRT
Data and Controller
Command and
instructions (8275)
Memory status
/O Bus Address /
/O Channel 2 Data Bus
Channel
DMA REQ2 Control
DMA Assembly /
Terminate 2 Disassembly
Register
File
nstruction
Fetch Unit
User Programmable Registers
Tag 19 0
G.P. Address A (GA)
15 0
ndex (IX)
19 0
Parameter Pointer (PP)
(Programmable
8086
interrupt S2-S0 (Processor status)
controller) AD15-AD0
A19-A16
IRn
RQ/GT0 BHE 8086/8088
Bus Interface
Components
Multi -Master
(Bus controller, System Bus
Bus request/grant latches and
transreceivers)
Interrupt
Ready, Clock request
and Reset
8284A
Clock
generator
Independent
Processor
(such as 8089)
Ready Reset
B15 B14 B13 B12 B11 B10 B9 B8 B7 B6 B5 B4 B3 B2 B1 B0
B4 B3
0 0 No termination by byte counter
0 1 Terminates when BC = 0; offset is set to 0
1 0 Terminates when BC = 0; offset is set to 4
1 1 Terminates when BC = 0; offset is set to 8
NOTE : Upon B2 B1 B0
termination of a
DMA operation 0 0 0 No termination by mask comparison
the channel 0 0 1 Terminates when comparison matches; offset is set 0
executes 0 1 0 Terminates when comparison matches; offset is set 4
the instruction 0 1 1 Terminates when comparison matches; offset is set 8
whose address 1 0 0 No effect
is the contents 1 0 1 Terminates when there is no match; offset is set 0
of TP plus an 1 1 0 Terminates when there is no match; offset is set 4
offset. 1 1 1 Terminates when there is no match; offset is set 8
Independent
Processor
(such as 8089)
Interrupt
request
Bus request/grant
RQ/GT0
IR0 MN/MX
(Programmable 8086
S2-S0 (Processor status)
interrupt
controller) AD15-AD0
RQ/GT1 A19-A16
IR1
TEST QS1-QS0 BHE 8086/8088
Bus Interface
Components
Multi -Master
(Bus controller, System Bus
Busy Queue status latches and
transreceivers)
Interrupt Bus
Ready, Clock request request/grant
and Reset
8284A
Clock
generator
Coprocessor
(such as 8087)
Ready Reset
7 07 0
Address SYS Bus
FFFF6H
FFFF8H SCB Address
FFFFAH
SCB Relocation
SOC
System
CB Address Configuration
Block
CB Relocation
BUSY CCW
BUSY CCW
PB Address Control Block
for
Parameter PB Relocation Channel 2
Block
TB Address
OP Task
User Defined
Program
P O B ICF ICF CF CF CF
PCU
A0 D2
PC7 10 31 D3
PC6 11 30 D4
8255A
PC5 12 29 D5
PC4 13 28 D6
PC0 14 27 D7
VCC
PC1 15 26
(+5 V)
PC2 16 25 PB7
PC3 17 24 PB6
PB0 18 23 PB5
PB1 19 22 PB4
PB2 20 21 PB3
PCL
GROUP GROUP A PA
A PORT A
POWER +5V CONTROL (8) PA7-PA0
SUPPLIES GND
GROUP A PCU
PORT C
BI-DIRECTIONAL Upper
DATA BUS (4) PC7-PC4
D7-D0 DATA
BUS
BUFFER 8 BIT
INTERNAL GROUP B PCL
DATA BUS PORT C
Lower
(4) PC3-PC0
RD
WR READ/ GROUP GROUP B PB
A0 WRITE
CONTROL B PORT B
A1 LOGIC CONTROL (8) PB7-PB0
RESET
CS
Data Bus
STB
Computer Printer
ACK
BUSY
PC 3 - PC7
D 3 - D1 ( B 2 B1 B 0 )
PC 0 - PC7
D0
0 D6 D5 D4 D3 D2 D1 D0
BIT SET/RESET
1 - SET
0 - RESET
Don't care
BIT SELECT
0 1 2 3 4 5 6 7
0 1 0 1 0 1 0 1 B0
0 0 1 1 0 0 1 1 B1
0 0 0 0 1 1 1 1 B2
PC 3 PC 4
D7
D7
1 D6 D5 D4 D3 D2 D1 D0
GROUP B
PORT C (LOWER)
1 = INPUT
0 = OUTPUT
PORT B
1 = INPUT
0 = OUTPUT
MODE SELECTION
0 = MODE 0
1 = MODE 1
GROUP A
PORT C (UPPER)
1 = INPUT
0 = OUTPUT
PORT A
1 = INPUT
0 = OUTPUT
MODE SELECTION
00 =MODE 0
01 = MODE 1
1X = MODE 2
CL
CU
1 0 0 1 1 0 0 0 = 98H
Port CL - Output
Port B - Output
Mode 0 Port B - Simple I/O
Port CU - input
Port A - Simple input
Mode 0 Port A - Simple I/O
I/O Mode
CL
CU
1 0 1 0 1 1 1 0 = AEH
Port CL - Output
Port B
Mode 1 Port B - Handshake
Port CU
Port A
Mode 1 Port A - Handshake
I/O Mode
0 X X X 0 0 0 1 = 01H
Make bit = 1
Bit 0 of Port C
Don't care
BSR Mode
0 X X X 0 0 0 0 = 00H
Make bit = 0
Bit 0 of Port C
Don't care
BSR Mode
Start
Call delay
Call delay
End
PC0
PC
1 0 1 1 0 1 0 X = B4 or B5
{
PA PCU Mode PB
Mode PA Input
PB Output
1 0 1 1 0 1 0 = B4H
I/O Port A Port C Mode 1 Port B Port C
Mode Mode 1 Input output Port B output
Port A
D7 D6 D5
D2
D 4 D 3 D1 D0
D7 D6 D5 D4 D3 D2 D1 D0
RD
Input
CS, A1, A0
D7-D0 Data
WR
D7-D0
CS, A1, A0
Output
PC 3 , PC 4 PC 5
PC 6 PC 7 D3
PC 3 , PC 6 PC 7
PC 4 PC 5 D3
PC 0 , PC1 PC 2
MODE 1(PORT A)
PA7-PA0 8
Control word
PC7, PC6
1 = INPUT
0 = OUTPUT
PC3 INTRA
RD 2
PC7-PC6 I/O
STBA
IBFA
INTR
RD
DATA ON
PA0-PA7
INTE A
PC 4
INTE B PC 2
MODE 1(PORT B)
PB7-PB0 8
Control word
PC0 INTRB
RD
IBFA
INPUT CONFIGURATION
A1 A 0 D7 D6 D5 D4 D3 D2 D1 D0
GROUP A GROUP B
MODE 1(PORT A)
PA7-PA0 8
Control word
D7 D6 D5 D4 D3 D2 D1 D0 PC7 OBFA
PC3 INTRA
WR 2
PC5-PC4 I/O
WR
OBFA
INTRA
ACKA
DATA
OUTPUT PREVIOUS DATA NEW DATA
ON
PA0-PA7
PC 6
PC 2
MODE 1(PORT B)
PB7-PB0 8
Control word
D7 D6 D5 D4 D3 D2 D1 D0 PC1 OBFB
1 1 0 PC2 ACKB
INTE
B
PC0 INTRB
WR
D7 D6 D5 D4 D3 D2 D1 D0
GROUP A GROUP B
PC 0 - PC 2
D7 D6 D5 D4 D3 D2 D1 D0
PC2-PC0
1 = INPUT
0 = OUTPUT
PORT B
1 = INPUT
0 = OUTPUT
GROUP B MODE
0 = MODE 0
1 = MODE 1
PC 6
PC3 INTRA
PA7-PA0 8
PC 4
PC7 OBFA
INTE
PC6 ACKA
1
GROUP A GROUP B
(DEFINED BY MODE 0
OR MODE 1 SELECTION)
Data from
CPU to 8255A
WR
tAOB
OBF
tWOB
INTR
tAK
ACK
tST
STB
tSIB
IBF
tPS
tAD tKD
Peripheral
bus
tPH tRBI
RD
Data from Data from
peripheral to 8255A 8255A to peripheral
Data from
8255A to 8080
28
( 2 16 )
PC 3 PC 0
D0 D0
D7 PA0
D7
A1 A0 PA7
A2 A1
PB0
M/IO
RD RD PB7
A0 PC0
8255
WR
WR PC7
A7 Reset
Reset CS
A6
A5
A4
A3
D0 D0
D7 D7 PA0 - PA7
A1 A0
PB0 - PB7
M/O A2 A1
RD RD 8255
PC0 - PC7
BHE
WR
WR
Reset out Reset
A15
CS
A14
A13
A12
A11
A10
A9
A8
A7
A6
A5
A4
A3
A 0 -A 1
D0 D0
D7 PA0
D7
A1 A0 PA7
A2 A1
PB0
M/IO
RD RD PB7
A0 PC0
8255
A19 WR
WR PC7
A18 Reset
A17 Reset Out CS
A16
A15
A14
A13
A12
A11
A10
A9
A8
A7
A6
A5
A4
A3
VCC
STB
GND OE 1 MEGABYTE
AD0-AD15 ADDRESS BUS
ADDR/DATA 8282
A16-A19 LATCH
(2 OR 3)
BHE
T
OE 16-BIT
8286 DATA BUS
TRANSCEIVER
(2) A2 A1
8
Y0
Y1
Reset A1 A0 RD WR D0 – D7
Addr Decoder
Y6 8255
EN Y7
2.5 K
AD0 AD0 13 14 Vref
PA0
A8
AD7 AD7 2.5 K
A1 2.5 K
PA7
IOR RD
8 0
IOW WR
2 8 4
–
5 0 Io
From Reset Reset 8 +
5
8086 out 2.5 K +
15 Vo
A1 A0
(1408)
A2 A1 –
CS
16 3 1 2
15 pF
VEE
A3
A4
A5
A6
A7
T = 10 ms
2.5 V
5 ms
0V
s –2.5 V
5 ms 5 ms
1
0.2 s
5 10 6
5.8 s
s s s
s
5 ms
8 s
AD0
D0
AD7 Vref
D7 8 D0
PA Rf
D7
IOR RD
PCL D8
4 D11 DAC
IOW WR 8255 IOUT –
Reset Reset +
A0 A0 + Vout
–
A1 A1
From
CS
address
decoder
5 ms
s
585
1
s
5 MHz
8.547 s
0.2 s
+2.5 V
0V 180º 360º
90º t
FFH
80H
96H
ABH
COH FEH
D2H
–2.5 V
E2H
EFH
F8H
3 1 28 2
Analog
4 2 27 1 inputs
Analog
inputs 5 3 26 0
6 4 25 A
7 5 24 B Address
SOC 6 23 C
EOC 7 ADC 22 ALE
0808/
DB3 8 0809 21 DB7
OUTPUT CONTROL 9 20 DB6
CLK 10 19 DB5
VCC 11 18 DB4
REF + 12 17 DB0
GND 13 16 REF
DB1 14 15 DB2
A
B Address
C 50 ns
ALE
25 s
SOC
EOC
DB0
Valid data
DB7
OE
VCC
+VREF
DB0 IN0
DB1 IN1
DB2 IN2
Input DB3 IN3 Analog
DB4 A IN4 inputs 1K
Port
DB5 D IN5
DB6 C IN6
DB7 0 IN7
EOC 8
0 CLK
8 +5 V
A 0.01 F
B Output
OUTPUT enable 7414
C
PORT VCC
SOC
ALE +REF 12 V
–REF GND
2K
+
LM308 2K 6.8 V
+ 10 mF –
1f solid
– Tantalum
10 K
Vin
Resolution
6.000
40 10 3
6 .035
40 10 3
(TC ) max
1 ( 255)
f 2 . 5 10 6
(TC ) max
(TC ) average
2
Clock 1 2 3 4 5 6 7 8
1
B8
B7 0
1
B6
1
B5
1
B4
B3 0
1
B2
1
B1
10
256
R 1
Y 1
G 1
W E
R Y G R Y G
3 3 3 4 4 4
R 2
Y 2
S G 2
+12 V
Free
wheeling
diode 230 V AC
50 Hz
5.1 K
AD0 PA0 BC 547
D0
AD7 D7 PA1
PA2
PA3
A0 A0
PA4
A1 A1 PA5
PB0 +12 V
IOR RD
PB1
Free
IOW WR PB2 wheeling
PB3 diode
RESET OUT RESET PB4
OF 8085/8086 5.1 K
PB5 BC547
CS
8255
A2 A
A3 B
A4 C Y0
A5 G1
A6 G2
A7 G 74LS138
MODE A
P
p
OBF
OBF
0 X X X 0 0 0 1 = 01H
0 X X X 1 0 0 0 = 08H
D3 - D1 ( B 2 B1 B 0 )
PC 0 - PC7
D0
Vref
2n
TM
Marking
Start
Time
Always low
1 Stop bit
Start bit
Mark
1 1 0 0 1 0 1 0
Transmitter Receiver
1 Frame
Time
11
2
Clock
Sync Sync
Transmitter Receiver
Data
Start Time
D2 D1
D3 D0
RxD VCC
GND RxC
D4 DTR
D5 RTS
D6 DSR
8251 A
D7 RESET
TxD CLK
WR TxD
CS TxEmpty
C/D CTS
RD SYN DET / BD
RxRDY Tx RDY
Data Transmit
D7-D0 bus buffer TxD
buffer (P-S)
RESET
CLK Read/Write
C/D control TxRDY
RD
Transmit
logic TxE
control
WR TxC
CS
DSR Receive
DTR Modem buffer RxD
CTS control (S-P)
RTS
Internal RRDY
data bus Receive
control RxC
SYNDET
1
2
D7 D6 D5 D4 D3 D2 D1 D0
Baud rate factor
00 SYN mode
01 ASYN1
10 ASYN16
11 ASYN64
Character length
00 5 bits
ASYN (D1D0 = 00) 01 6 bits
10 7 bits
11 8 bits
D7 D6 D5 D4 D3 D2 D1 D0
Internal reset
Data terminal ready
1 = Resets
1 = Enable DTR
8251 to mode
Receive enable
Request to send
1 = Enable
1 = Enable RTS
0 = Disable
SYNDET/
DSR FE OE PE TEMPTY RRDY TRDY
BRKDET
Note 1
Same definitions as I/O pins
Parity error
The PE flag is set when a parity error is
detected. It is reset by the ER bit of the
command instruction. PE does not inhibit
operation of the 8251A.
Overrun error
The OE flag is set when the CPU does
not read a character before the next one
becomes available. It is reset by the ER
bit of the command instruction.OE does
not inhibit operation of the 8251 A. However,
the previously overrun character is lost.
1 1
16 64
Start Parity Stop
RxD Data bits
bit bit bits
TxEMPTY
D0 D0-D7
D7 TxD
M/IO
RD RD
A0
8251A
WR
WR
M/IO
RD RD
A0
8251A
WR
WR
CS
DSR DTR
TxD Marking Start Parity Stop
Data bits bit(s)
bit bit
TM
RD CLK1
Read/ Counter
WR
write GATE1
A0 logic 1
A1 OUT1
CS
CLK2
Control Counter
word GATE2
register 2
OUT2
Internal bus
A0
D7 D6 D5 D4 D3 D2 D1 D0
SC1 SC0 RW1 RW0 M2 M1 M0 BCD
1 0 Read / Write most significant byte only 1 Binary coded decimal (BCD)
Counter (4 Decades)
Read / write least significant byte first,
1 1 then most significant byte
Note : Don't care bits () should be 0 to ensure compatibility with future Intel products
CW = 10 LSB = 4 (a) Normal operation
WR
CLK
GATE
OUT
0 0 0 0 0 FF FF
N N N N
4 3 2 1 0 FF FE
CW = 10 LSB = 3 (b) Gate disable
WR
CLK
GATE
OUT
0 0 0 0 0 0 FF
N N N N
3 2 2 2 1 0 FF
CW = 10 LSB = 3 LSB = 2 (c) New count
WR
CLK
GATE
OUT
0 0 0 0 0 0 FF
N N N N
3 2 1 2 1 0 FF
CLK
GATE
OUT
0 0 0 0 FF 0 0
N N N N N
3 2 1 0 FF 3 2
CW = 12 LSB = 2 (b) Retriggering
WR
CLK
GATE
OUT
0 0 0 0 0 0 0
N N N N N
3 2 1 3 2 1 0
CW = 12 LSB = 3 LSB = 4 (c) New count
WR
CLK
GATE
OUT
0 0 0 FF FF 0 0
N N N N N
2 1 0 FF FE 4 3
CW = 14 LSB = 3 (a) Normal operation
WR
CLK
GATE
OUT
0 0 0 0 0 0 0
N N N N
3 2 1 3 2 1 3
CW = 14 LSB = 3 (b) Gate disable
WR
CLK
GATE
OUT
0 0 0 0 0 0 0
N N N N
3 2 2 3 2 1 3
CW = 14 LSB = 4 LSB = 5 (c) New count
WR
CLK
GATE
OUT
0 0 0 0 0 0 0
N N N N
4 3 2 1 5 4 3
Note : A GATE transition should not occur one clock prior to terminal count.
CW = 16 LSB = 4 (a) Even count
WR
CLK
GATE
OUT
0 0 0 0 0 0 0 0 0 0
N N N N
4 2 4 2 4 2 4 2 4 2
WR
CLK
GATE
OUT
0 0 0 0 0 0 0 0 0 0
N N N N
4 2 0 4 2 4 2 0 4 2
WR
CLK
GATE
OUT
0 0 0 0 0 0 0 0 0 0
N N N N 2
4 2 4 2 2 2 4 4 2
Note : A GATE transition should not occur one clock prior to terminal count.
CW = 18 LSB = 3 (a) Normal operation
WR
CLK
GATE
OUT
0 0 0 0 FF FF FF
N N N N
3 2 1 0 FF FE FD
CW = 18 LSB = 3 (b) Gate disabled
WR
CLK
GATE
OUT
0 0 0 0 0 0 FF
N N N N
3 3 3 2 1 0 FF
CW = 18 LSB = 3 LSB = 2 (c) New count
WR
CLK
GATE
OUT
0 0 0 0 0 0 FF
N N N N
3 2 1 2 1 0 FF
CW = 1A LSB = 3 Normal operation
WR
CLK
GATE
OUT
0 0 0 0 FF 0
N N N N N
3 2 1 0 FF 3
CW = 1A LSB = 3 Retriggering
WR
CLK
GATE
OUT
0 0 0 0 0 0 FF
N N N N N N
3 2 3 2 1 0 FF
CW = 1A LSB = 3 LSB = 5 New count
WR
CLK
GATE
OUT
0 0 0 0 FF FF 0 0
N N N N N
3 2 1 0 FF FE 5 4
1 MHz
1 kHz
1 10 3
1 1 . 5 10 6
A0
A15
A2 A1
D0
D15
M/IO
IOR
RD
A0
IOW
WR
D7 - D0 A1 A0 RD WR
CS 8253
Output
square wave
+5 V
74LS138 1.5 MHZ
Clock
A7 A D generator
A6 B E
C
A5 C O
D Y1
A4 G1
A3 E
G2 R
D0 D0 CLK0
GATE0
D7 D7 OUT0
A1 A0
A2 A1 CLK1
GATE1
M/IO
RD OUT1
RD
IOR
A0
CLK2
WR
WR IOW GATE2
8253/54 OUT 2
A3
A4
A5 CS
A6
A7
D0 D0 CLK0
GATE0
D7 D7 OUT0
A1 A0
A2 A1 CLK1
GATE1
M/IO
RD OUT1
RD
A0 IOR
WR CLK2
WR IOW GATE2
8253/54
OUT2
A3
A4
A5
A6
A7
A8
A9 CS
A10
A11
A12
A13
A14
A15
RD WR IO
A 1 -A 2
A 3 - A 19
D0 D0 CLK0
GATE0
D7 D7 OUT0
A0 A0
A1 A1 CLK1
GATE1
RD OUT1
RD
A0 M/IO
WR CLK2
WR GATE2
8253/54
OUT2
CS
A3 A4 A5 A6 A7 A8 A9A
10 A11 A12 A13 A14 A15 A16 A17A18 A19
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
A0
A15
A2 A1 A2 A1
D0
D7
M/IO
RD IOR
A0
IOW
WR
Reset out
D7 D0 A1 A0 RD WR D7 D0 A1 A0 RD WR Reset
CS 8253 / 54 PC0 8255 CS
O2 O0
O1
VCC
VCC
A3 A Y0
A4 B
3:8 CLK1
A5 C 10 kHz
Decoder Y1
A6 G1 R
A7 G2 CLK
generator
230 V Alarm
AC
Required period
Clock period
1 sec
1 10 4
100s
TM
RD RL5 6 35 SL3
WR 8 RL6 7 34 SL2
2 SL0 -3 4 Scan
RL7 8 33 SL1
7
CS 9 RESET 9 32 SL0
DB1 13 28 OUT B3
CLK
data
DB2 14 27 OUT A0
DB3 15 26 OUT A1
BD DB4 16 25 OUT A2
DB5 17 24 OUT A3
VSS DB6 18 23 BD
DB7 19 22 CS
Vss 20 21 A0
Display Timing
registers and
control Scan counter Return
8
Shift
-
OUT A0 A3 OUT B0 B3 - BD SL0-SL3 RL0-RL7 CNTL/ STB
SC 3 - SC 0
SC 3 - SC 0
8 4
RL 7 - RL 0
88
16 8
SL 2 - SL 0
88
(28 )
SC 3 – SC 0
8 4
(27 )
88
8 4
8 8
A0
WR
8 4
8 4
8 4
External clock
100 kHz
2 10 6
10100 2
100 10 3
00110100 2
B4
B4 B4
B4 B4
B3 B0
CD1 CD0
CD 2
CD 1 CD 2
DU S/E O U F N N N
Indicates number
of characters in FIFO
FIFO full
Error under run
Error overrun
Sensor closure / Error flag for multiple closures
Display unavailable
D0 D0 SHIFT
D7 D7
CNTL
A1 A0 RL0 Return lines
RL7
IOR RD 8
2 BD Blank display
IOW WR 7
S0
9 Scan lines
S3
RESET RESET
A0
CLOCK CLK A3
Display
To 8086 Interrupt B0 lines
INT
B3
CS
A15
A2
A19
A18
A17
A16
D0 D0 SHIFT
A15 D7 D7
CNTL
A14 A1 A0 RL0
RL7 Return lines
A13
MEMR RD
8 BD Blank display
A12 2
MEMW WR 7
A11 S0
9 S3 Scan lines
RESET RESET
A10
A0
CLOCK CLK A3
A9 Display
To 8086 Interrupt B0 lines
A8 INT
B3
CS
A7
A6
A5
A4
A3
A2
Microprocessors and Microcontrollers 12 - 23 Keyboard / Display Controller - 8279
In this section we will discuss many useful applications with different modes of
keyboard and display interfacing. In addition to this we are going to see the software
requirement to control the interfacing circuits. All these applications are illustrated using
different examples.
Scan lines
D0 D0 RL0
D7 D7
RL1
RL2
A1 A0
Return lines
RL3
IOR RD
RL4
IOW WR
RL5
RESET OUT RESET
RL6
CLK OUT CLK
RL7
Y0
8279
S0
S1 3:8
Decoder
S2
INT S3
Y7
A7
SHIFT
A6
CNTL
A5 CS
A4
A3
A2
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
Microprocessors and Microcontrollers 12 - 24 Keyboard / Display Controller - 8279
I/O Map
Address lines
Data/Control Register Address
A7 A6 A5 A4 A3 A2 A1 A0
Software :
0 0 0 D D K K K
0 0 0 X X 0 0 0 = 00H
= 20 = 10100 2
0 0 1 1 0 1 0 0 = 34H
Step 3 : Find Read FIFO/sensor RAM command word we want to read first entry
from the FIFO RAM. Therefore command word is as given below.
AI A A A
0 1 0 0 X 0 0 0 = 40H
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
Microprocessors and Microcontrollers 12 - 25 Keyboard / Display Controller - 8279
Flowchart :
Start
Initialize keyboard /
display mode of 8279
Initialize prescaler
count
Is
no. of
Yes characters
in FIFO = 0
?
No
End
Program :
MOV AL, 00H
OUT 81H, AL ; Initialize keyboard/display
; in encoded scan keyboard-2 keylockout mode
MOV AL, 34H
OUT 81H, AL ; Initialize prescaler count
BACK : IN AL, 81H ; Read FIFO status word
AND AL, 07H ; Mask bit B3 to B7
JZ BACK ; If 0, key is not pressed wait for key
; press otherwise read FIFO RAM
MOV AL, 40H ; Initialize 8279 in read
OUT 81H, AL ; FIFO RAM mode
IN AL, 80H ; Read FIFO RAM (keycode)
Hardware :
Fig. 12.8.2 shows the interfacing of 8 8 matrix keyboard in interrupt driven keyboard
mode.
In the interrupt driven mode interrupt line from 8279 is connected to the INTR the
interrupt input of 8086.
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
Microprocessors and Microcontrollers 12 - 26 Keyboard / Display Controller - 8279
D0 D0 RL0
D7 D7
RL1
RL2
A1 A0
RL3
IOR RD
RL4
IOW WR
RL5
RESET OUT RESET
RL6
CLK OUT CLK
RL7
To RST 7.5 INT 8279
S0 A
A7
S1 B
A6 S2 C
3:8
A5 Decoder
A4 CS
A3
A2
Software : All the command words required to initialize 8279 are same as in the non
interrupt mode
Flowchart :
Start Start
Enable interrupt
Initialize prescaler count
Return
Enable interrupt
Fig. 12.8.3
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
Microprocessors and Microcontrollers 12 - 27 Keyboard / Display Controller - 8279
Main Program
MOV AL, 00H
OUT 82H, AL ; Initialize keyboard/display in encoded
; scan keyboard 2 key lockout mode
MOV AL, 34H
OUT 82H, AL ; Initialize prescaler count
HERE : JMP HERE ; Wait for the interrupt
Interrupt Subroutine
MOV AL, 40H ; Initialize 8279 in read FIFO
OUT 82H, AL ; RAM mode
IN AL, 80H ; Read FIFO RAM (keycode)
RET ; Return to main program
In the interrupt driven keyboard, when key is pressed, key code is loaded into FIFO
RAM and interrupt is generated. This interrupt signal is used to tell CPU that there is a
keycode in the FIFO RAM. CPU then initiates read command with in the interrupt
service routine to read keycode from the FIFO RAM.
Program 2 : Hardware and software to interface 8 4 matrix keyboard using 8279
Program Statement : Interface an 8 4 matrix keyboard to 8086 through 8279.
Solution : Fig. 12.8.4 shows interfacing of an 8 4 matrix keyboard to 8086 through 8279.
As keyboard is having 8 rows and 4 columns, only 4 scan lines are required and we can
avoid external decoder to generate scan lines by selecting decoded scan keyboard mode.
D0 D0 RL0
D7 D7
RL1
RL2
A1 A0
RL3
IOR RD
RL4
IOW WR 8279
RL5
RESET OUT RESET
RL6
CLK OUT CLK
RL7
To RST 7.5 INT S0
S1
S2
S3
A7
SHIFT
A6
CNTL
A5 CS
A4
A3
A2
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
Microprocessors and Microcontrollers 12 - 28 Keyboard / Display Controller - 8279
Main Program
MOV AL, 00H
OUT 82H, AL ; Initialize keyboard/display in encoded
; scan keyboard 2 key lockout mode
MOV AL, 34H
OUT 82H, AL ; Initialize prescaler count
HERE : JMP HERE ; Wait for the interrupt
Interrupt Subroutine
MOV AL, 40H ; Initialize 8279 in read FIFO
OUT 82H, AL ; RAM mode
IN AL, 80H ; Read FIFO RAM (keycode)
RET ; Return to main program
Program 3 : Hardware and software to interface eight 7-segment digits using 8279
Number h g f e d c b a Code
1 0 0 0 0 0 1 1 0 06
2 0 1 0 1 1 0 1 1 5B
3 0 1 0 0 1 1 1 1 4F
4 0 1 1 0 0 1 1 0 66
5 0 1 1 0 1 1 0 1 6D
6 0 1 1 1 1 1 0 1 7D
7 0 0 0 0 0 1 1 1 07
8 0 1 1 1 1 1 1 1 7F
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
Microprocessors and Microcontrollers 12 - 29 Keyboard / Display Controller - 8279
h
a
Y0
Y7
+VCC
B 74138
G2
G
+VCC
+VCC
VCC
G1
C
A
S0
S1
S2
B0
A3
8279
CS
RESET
CLK
WR
INT
RD
A0
D0
D7
A1
CLK OUT
RESET OUT
IOR
IOW
D0
D7
A7
A6
A5
A4
A3
A2
Fig. 12.8.5
D D K K K
0 0 0 0 0 0 0 0 = 00H
Step 2 : Find program clock command word. External clock frequency is 3 MHz.
3 MHz
Prescaler value = = 30 = 11110 2
100 MHz
Therefore, the program clock command word is as given below.
P P P P P
0 0 1 1 1 1 1 0 = 3EH
Step 3 : Find write display RAM command word. We want to write first eight
locations of display RAM with corresponding 7 segment codes. So we start from first
location with autoincrement mode by command word given below.
AI A3 A2 A1 A0
1 0 0 1 0 0 0 0 = 90H
Flowchart :
Start
Initialize Keyboard /
Display mode of 8279
Decrement counter
No Is
counter = 0
?
Yes
End
Fig. 12.8.6
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
Microprocessors and Microcontrollers 12 - 31 Keyboard / Display Controller - 8279
Program :
MOV SI, LOOK_UP_TABLE ; Initialize lookup table pointer
MOV CL, 08H ; Initialize counter
MOV AL, 00H ; Initialize keyboard/display
OUT 82H, AL ; Mode
MOV AL, 3EH ; Initialize prescaler count
OUT 82H, AL
MOV AL, 90H ; Initialize 8279 in write Display
OUT 82H, AL ; RAM mode
BACK : MOV AL, [SI] ; Get the 7-segment code
OUT 80H, AL ; Write 7-segment code in display RAM
INC SI ; Increment lookup table pointer
DCR CL ; Decrement counter
JNZ BACK ; if count = 0 stop otherwise go to back
LOOK_UP-TABLE dB 66H, 5BH, 4FH, 66H, 6DH, 7DH, 07H, 7FH
Example 12.8.1 Interface 4 4 matrix keyboard and 6 displays to the 8086 system using
8279 IC. Write an initialization program for encoded key scan and left entry for display.
PU : May-06
X X X 0 0 0 0 0 = 00H
Fig. 12.8.8
Review Questions
1. Explain how to interface the hex key pad and 7-segment LEDs using 8279.
AU : May-10, Marks 16
2. How do you interface a keyboard and the display using keyboard / display controller ?
AU : Dec.-12, Marks 8
3. Develop a 8086 based system to display in the word HELLO for every 2 ms in the common
cathode seven segment. LED display and check how many times the work displayed for one hour.
AU : May-17, Dec.-17, Marks 15
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
+ VCC
D0 D0 B0
D7 D7
A3
A1 A0
Microprocessors and Microcontrollers
IOR RD
IOW WR
0
RESETOUT RESET S0 1
S1 3:8 2
TECHNICAL PUBLICATIONS
8279 Decoder 3
CLK OUT CLK
®
12 - 32
S2 4
Fig. 12.8.7
5
INTR INT
A7
RL0
A6 RL1
A5 RL2
CS
RL3
A2
Keyboard / Display Controller - 8279
Microprocessors and Microcontrollers 12 - 33 Keyboard / Display Controller - 8279
Ans. : The scan counter has two modes to scan the key matrix and refresh the display.
In the encoded mode, the counter provides binary count that is to be externally
decoded to provide the scan lines for keyboard and display. In the decoded scan mode,
the counter internally decodes the least significant 2 bits and provides a decoded 1 out
of 4 scan on SL0-SL3. The keyboard and display both are in the same mode at a time.
Q.2 What is the output modes used in 8279 ?
Ans. : 8279 provides two output modes for selecting the display options.
Ans. : a. Keyboard section b. Scan section c. Display section d. CPU interface section
Q.7 What is key bouncing ? AU : June-06, 08, 16
Ans. : Mechanical switches are used as keys in most of the keyboards. When a key is
pressed the contact bounce back and forth and settle down only after a small time
delay (about 10 ms). Even though a key is actuated once, it will appear to have been
actuated several times. This problem is called key bouncing.
Q.8 How much current is needed to drive an LED ? Draw a typical driver circuit for
it. AU : May-05
Ans. : Around 15 mA current is needed to drive LED. The typical driver circuit for
LED is shown in Fig. 12.1.
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
Microprocessors and Microcontrollers 12 - 34 Keyboard / Display Controller - 8279
+ VCC
LED
R
RB
Port pin
Fig. 12.1
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
Microprocessors and Microcontrollers 12 - 35 Keyboard / Display Controller - 8279
Q.14 What is the necessity for a separate 8279 keyboard display controller ?
Ans. : In software approach, to drive multiplexed displays CPU has to look after digit
selection in synchronism with the data for specific digit and these displays need
continuous refreshing. This puts a lot of burden on the CPU. In keyboard interface to
provide facilities such as 2-key lockout, N-key Rollover CPU needs to execute necessary
programs which further increases the burden on CPU and hence it is necessary to have
separate 8279 keyboard/display controller.
Q.15 How a keyboard matrix is formed in keyboard interface using 8279 ?
(Refer section 12.8)
Q.16 What is the function of scan section in 8279 programmable keyboard/display
controller ? (Refer section 12.5.1) AU : May-11
qqq
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
Microprocessors and Microcontrollers 12 - 36 Keyboard / Display Controller - 8279
Notes
®
TECHNICAL PUBLICATIONS - An up thrust for knowledge
TM
CONTROL LOGIC
D7-D0 DATA
BUS
BUFFER
INTERNAL BUS
RD
READ/
WR WRITE IR0
LOGIC IR1
A0 INTERRUPT INTERRUPT IR2
SERVICE PRIORITY REQUEST IR3
REG RESOLVER REG IR4
CS IR5
(ISR) (IRR)
IR6
CAS0 IR7
CASCADE
CAS1 BUFFER
COMPARATOR
INTERRUPT MASK REG (IMR)
CAS2
SP/EN
CAS 0 CAS 2
R3
ICW1
ICW2
Is
NO (SNGL = 1) CASCADE
MODE
?
YES (SNGL = 0)
ICW3
Is
NO (ICW4 = 0) ICW4
NEEDED
?
YES (IC4 = 1)
ICW4
READY TO ACCEPT
INTERRUPT REQUESTS
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 = ICW4 NEEDED
0 = NO ICW4 NEEDED
1 = SINGLE
0 = CASCADE MODE
A7-A5 OF INTERRUPT
VECTOR ADDRESS
(MCS - 80/85 MODE ONLY)
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 S7 S6 S5 S4 S3 S2 S1 S0
1 = 8086/8088 MODE
0 = MCS - 80/85 MODE
1 = AUTO EOI
0 = NORMAL EOI
1 = SPECIAL FULLY
NESTED MODE
0 = NOT SPECIAL FULLY
NESTED MODE
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 M7 M6 M5 M4 M3 M2 M1 M0
INTERRUPT MASK
1 = MASK SET
0 = MASK RESET
A0 D7 D6 D5 D4 D3 D2 D1 D0
0 R SL EOI 0 0 L2 L1 L0
0 1 2
0 1 0
0 0
0 0
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 = POLL COMMAND
0 = NO POLL COMMAND
RESET SET
NO
SPECIAL SPECIAL
ACTION
MASK MASK
+5 V
A15 VCC G
G2 Y0
Address
bus A4
A3 C 74LS138
A2 B
A1
A0 A +5 V
M/IO G1
GND
SP/EN VCC
CS IR0
Control
bus A0 IR1
RD RD IR2
WR WR IR3
INTR INT IR4
INTA INTA IR5
D0 D0 8259A IR6
D1 D1 IR7
D2 D2 CAS0
Data D3 D3 CAS1
bus D4 D4 CAS2
D5 D5
D6 D6
D7 D7 GND
F F F 0/ 2
+5 V
A 15
VCC G
G2 Y0
Address Y2
bus A4
Y4
A3 C 74LS138
A2 B
A0 A +5 V
M/IO G1
GND
SP/EN
/ VCC
CS IR0
Control
bus A1 A0 IR1
RD RD IR2
WR WR
INT INT IR3
INTA INTA IR4
D0 D0 8259-1 IR5
D1 D1 IR6
D2 D2 IR7
Data D3 D3
bus CAS0
D4 D4
CAS1
D5 D5
CAS2
D6 D6
D7 D7 GND
+5 V
SP/EN
/ VCC
CS IR0
A0 IR1
RD IR2
WR
IR3
INTA IR4
D0 8259-2 IR5
D1 IR6
D2 IR7
D3
D4
D5 CAS0
D6 CAS1
D7 CAS2
GND INT
+5 V
VCC
8259-3
SP / EN INT
GND CAS0 CAS1 CAS2
TM
Control Bus A
Control Bus
IOR , IOW
HLDA HOLD MEMR , MEMW B
HRQ
DMA
HLDA Controller Control Bus
Peripheral
IOR , IOW Device
MEMR , MEMW
(disk
DREQ Controller)
DACK0
IOR 1 40 A7
IOW 2 39 A6
MEMR 3 38 A5
MEMW 4 37 A4
VCC 5 36 EOP
READY 6 35 A3
HLDA 7 34 A2
ADSTB 8 33 A1
AEN 9 8237A/ 32 A0
HRQ 10 8237A-4/ 31 VCC (+5 V)
CS 11 8237A-5 30 DB0
CLK 12 29 DB1
RESET 13 28 DB2
DACK2 14 27 DB3
DACK3 15 26 DB4
DREQ3 16 25 DACK0
DREQ2 17 24 DACK1
DREQ1 18 23 DB5
DREQ0 19 22 DB6
(GND)Vss 20 21 DB7
MEMR, MEMW
MEMR
MEMW
IOR IOW
IOR IOW
EOP
EOP
EOP
EOP Decrementor Inc/decrementor
A0-A3
RESET Temp Word Temp Address I/O Buffer
CS Count Reg (16) Reg (16)
READY 16 BIT BUS
CLOCK 16 BIT BUS Output A4-A7
Timing
AEN And
Read Buffer Read / Write Buffer
Buffer
Control
ADSTB Base Current A -A
Base Current 8 15
Word Word
MEMR Address Count Address Count
(16) (16) (16) (16) Command
MEMW Control
IOR
IOW
Write Buffer Read Buffer D0 -D1
DB0 -DB7
DREQ0- 4 Command (8) Internal Data Bus I/O Buffer
DREQ3 Priority
Encoder
HLDA
And
Rotating Mask (4)
HRQ
Priority
DACK0- 4
Logic Read Write
DACK3
Mode Status (8) Temporary (8)
Request (4) (4x8)
EOP
Start Start Start
Is
Is Is
I/O device No
I/O device No I/O device No ready for
ready for ready for
data transfer
data transfer data transfer
?
? ?
Yes
Yes Yes
DMA acquires
DMA acquires DMA acquires the control of
the control of the control of buses from processor
buses from processor buses from processor
8237A
DREQ HRQ
DACK HLDA
8237A
ADDITIONAL
DEVICES
EOP
TC
DRQ7 HOLD
DAK7 HLDA
DRQ6
AEN
Microprocessor
DAK6
DRQ5 Master
DMA
DAK5 Controller
DRQ4
TC DAK4
IOWC
IORC
MWTC
MRDC
TC
A8-A1
HOLD
HLDA
DRQ3
DAK3
DRQ2
DRQ0 IORC
DAK0 IOWC
A7-A0
D7-D0
EOP
st nd rd
1 2 3
Service Service Service
Highest 0 2 Service 3 Service
1 Service 3 Request 0
2 0 1
Lowest 3 1 2
A15 - A2 ADDRESS BUS
A15 A8
OE
STB
A3 - A0 A7- A4 AEN LATCH
ADSTB
HLDA
8237A-5
HRQ DB0
DACK0-3
DRQ0-3
RESET
MWRC
MRDC
CLK
IOW
DB7
IOR
4 4
CLK
RESET
MRDC
MWRC
IOR
IOW
D7 - D0 DATA BUS
TM
30 pF 30 pF P0 P1 P2 P3 TxD RxD
Multiplexed
data/address
4 to 30 MHz
Higher order Multi-functional
normally 11.0592 MHz address
16-bit DPTR
Memory
DPH DPL
(83H) (82H)
Address
16
8-bit 8-bit
B7 B6 B5 B4 B3 B2 B1 B0
ADDITION SUBTRACTION
9B H 1 0 0 1 1 0 1 1
+
65 H 0 1 1 0 0 1 0 1
1 0 0 0 0 0 0 0 0
Accumulator
Direct Bit address Hardware
byte register
address symbol
(MSB) (LSB)
0FFH
0F0H F7 F6 F5 F4 F3 F2 F1 F0 B
0E0H E7 E6 E5 E4 E3 E2 E1 E0 ACC
0D0H D7 D6 D5 D4 D3 D2 D1 D0 PSW
0B0H B7 B6 B5 B4 B3 B2 B1 B0 P3
0A0H A7 A6 A5 A4 A3 A2 A1 A0 P2
98H 9F 9E 9D 9C 9B 9A 99 98 SCON
90H 97 96 95 94 93 92 91 90 P1
88H 8F 8E 8D 8C 8B 8A 89 88 TCON
80H 87 86 85 84 83 82 81 80 P0
P1.0 1 40 VCC + 5 V
P1.1 2 39 P0.0 (AD0)
P1.2 3 38 P0.1 (AD1)
P1.3 4 37 P0.2 (AD2)
Port 1
P1.4 5 36 P0.3 (AD3)
Port 0
P1.5 6 35 P0.4 (AD4)
P1.6 7 34 P0.5 (AD5)
P1.7 8 33 P0.6 (AD6)
RST 9 32 P0.7 (AD7)
P3.0 (RXD) 10 8051 31 EA (VPP)
P3.1 (TXD) (40-pin)
11 D IP 30 ALE (PROG)
P3.2 (INT0)
12 29 PSEN
P3.3 (INT1) P2.7 (A15)
13 28
Port 3 P3.4 (T0)
14 27 P2.6 (A14)
P3.5 (T1) 15 26 P2.5 (A13)
R0 R7
Program memory
FFFFH FFFFH
EA = 0
60 kbytes Access
External External
memory 64 kbytes
OR External
1000H
0FFFH
4 kbytes EA = 1
Internal Access
0000 Internal 0000
memory
Data memory
(SFRs)
FFH FFFFH
Accessible by
Accessible by
indirect
Upper direct
addressing
128 addressing
only
AND 64 kbytes
80H external
7FH memory
Accessible by
Lower direct & indirect
128 addressing
0 0000H
Byte
address Byte
address
1F R7 7F
1E R6
1D R5
1C R4
Bank 3
1B R3
1A R2
19 R1
18 R0
17 R7
16 R6
15 R5
14 R4
Bank 2
13 R3
12 R2
11 R1
10 R0 B7 B6 B5 B4 B3 B2 B1 B0
0F R7 7F 7E 7D 7C 7B 7A 79 78 2F
0E R6 77 76 75 74 73 72 71 70 2E
0D R5 6F 6E 6D 6C 6B 6A 69 68 2D
0C R4 67 66 65 64 63 62 61 60 2C
Bank 1
0B R3 5F 5E 5D 5C 5B 5A 59 58 2B
0A R2 57 56 55 54 53 52 51 50 2A
09 R1 4F 4E 4D 4C 4B 4A 49 48 29
08 R0 47 46 45 44 43 42 41 40 28
07 R7 3F 3E 3D 3C 3B 3A 39 38 27
06 R6 37 36 35 34 33 32 31 30 26
05 R5 2F 2E 2D 2C 2B 2A 29 28 25
04 R4 27 26 25 24 23 22 21 20 24
Bank 0
03 R3 1F 1E 1D 1C 1B 1A 19 18 23
02 R2 17 16 15 14 13 12 11 10 22
01 R1 0F 0E 0D 0C 0B 0A 09 08 21
00 R0 07 06 05 04 03 02 01 00 20
30
Register Bit addresses Byte General purpose
bank addresses
On-chip RAM On-chip RAM On-chip RAM
08 09
09
SP 07 08
Data 08
06 SP 07
Stack pointer SP SP+1 07
Data 1 09 Data 2 09
SP Data 2 08 Read 08
Data 3 07 SP SP–1 07
Stack pointer
VCC I CC
PSEN
TM
Memory
Destination register
Address of memory
within the instruction
Data from
selected memory
location
Memory
Register
Destination register
Contents of register are
used to point memory
Data from
selected memory
location
Destination register
Data specified
in the instruction
DPTR Register
Program memory
+
Data from Address of
selected memory memory
Contents of register A
X X X X X X X X Unknown 8-bit binary number
1 1 1 1 0 0 0 0 Masking pattern
X X X X 0 0 0 0 Result
Masked bits
+ 1 1 1 1 0 0 0 0 Setting pattern
1 1 1 1 X X X X Result
Set bits
X X X X X X X X Result
Inverted bits
7 6 5 4 3 2 1 0
C 7 6 5 4 3 2 1 0
Carry flag
7 6 5 4 3 2 1 0
7 6 5 4 3 2 1 0 C
Carry
flag
7 4 3 0
Higher nibble Lower nibble
12
Crystal frequency
12
11.0592 10 6
12
11.0592 10 6
12
11.0592 10 6
Mnemonic Source operand
. asm
. lst
Assembler
Program listing
Converts assembly
instruction to object
code Error messages
. abs
0H Program
Converts object code
file into executable file
. hex
Executable file
Start
Get the number
Number 100
Number Remainder
Hund_digit Quotient
Number 10
Ten_digit Quotient
One_digit Remainder
Stop
Start
Stop
Start
Initialize pointer
to memory
Initialize counter
Maximum number = 0
Is
Number > Yes
Max. number
?
Max. number Number
No
Decrement counter
No Is
counter = 0
?
Yes
Stop
Start
Initialize counter 1
Initialize counter 2
Increment
memory pointer
Is
(pointer) > Yes
(pointer + 1)
?
Interchange contents of
compared memory locations
No
Decrement counter 2
No Is
counter 2 = 0
?
Yes
Decrement counter 1
Fig. 1
No Is
counter 1 = 0
?
Yes
Stop
Start
Initialize count = 0
Initialize counter = 8
Rotate contents of
accumulator so that
LSB will go in carry
No Is
carry = 1
?
Yes
Increment count
Decrement counter
No Is
counter = 0
?
Yes
Stop
Start
Sum=0
Pointer = 2201H
Count = (2200H)
Pointer = Pointer +1
Count = Count – 1
No Is
Count = 0
?
Yes
(2300H) = Sum
End
Start
Sum high = 0
Sum low = 0
Pointer = 2201H
Count = (2200H)
No Is
Carry 1
?
Yes
Pointer = Pointer + 1
Count = Count – 1
No Is
Count = 0
?
Yes
(2300H) = Sum low
(2301H) = Sum high
End
Start
Initialize counter = 10
No Is
Count = 0
?
Yes
End
R0
TM
Read latch
P0.X
Pin
Internal bus D Q
P0.X
Latch Mux
Write to latch CL Q
Control logic
Read pin
VCC
Read latch
Internal
pull-up
P1.X
Internal bus D Q Pin
P1.X
Latch
Write to latch CL Q
Read pin
VCC
Addr bus
Control
Read latch
Internal
pull-up
Internal bus D Q
P2.X
P2.X
Latch
Pin
Write to latch CL Q
MUX
Control logic
Read pin
VCC
Alternate
output
function Internal
Read latch
pull-up
P3.X
Pin
Internal bus D Q
P3.X
Latch
Write to latch CL Q
Read pin
Alternate
input
function
VCC
P0.0
P0.1
P0.2
P0.3
8051 Port 0
P0.4
P0.5
P0.6
P0.7
Timer 1 register Timer 0 register
(MSB) (LSB)
Timer 1 Timer 0
(MSB) (LSB)
TR1
GATE Control
INT1 PIN
TH0 TL0
OSC 12 (8 Bits) (8 Bits) TF0 Interrupt
C/T=0
TR0
GATE(TMOD.3) Control
INT0 PIN
TMOD X X X X 0 0 0 1 = 01
TR0
TH1 TL1
OSC 12 (8 Bits) (8 Bits) TF1 Interrupt
C/T=0
TR1
GATE(TMOD.7) Control
INT1 PIN
TMOD 0 0 0 1 X X X X = 10H
TR1
TL0
OSC 12 (8 Bits) TF0 Interrupt
C/T=0
TR0
GATE(TMOD.3) TH0
Control (8 Bits)
INT0 PIN
TMOD X X X X 0 0 1 0 = 02H
TR0
TL1
OSC 12 (8 Bits) TF1 Interrupt
C/T=0
TR1
GATE(TMOD.7) TH1
Control (8 Bits)
INT1 PIN
TMOD 0 0 1 0 X X X X = 20H
TR1
C/T=0 TL0
(8 Bits) TF 0 Interrupt
C/T=1
T0 PIN
TR0
GATE Control
INT0 PIN
TH0
1/12 f OSC (8 Bits) TF 1 Interrupt
Control
TR1
C T T
T
TH0 TL0
T0(P3.4) (8 Bits) (8 Bits) TF0 Interrupt
C/T=1
TR0
GATE(TMOD.3) Control
INT0 PIN
TR0
TMOD X X X X 0 1 0 1 = 05H
7 6 5 4 3 2 1 0
TCON 0 0 0 1 0 0 0 0 = 10H
TH1 TL1
T1(P3.5) (8 Bits) (8 Bits) TF1 Interrupt
C/T=1
TR1
GATE(TMOD.7) Control
INT1 PIN
TR1
TMOD 0 1 0 1 X X X X = 50H
7 6 5 4 3 2 1 0
TCON 0 1 0 0 0 0 0 0 = 40H
TL0
T0(P3.4) (8 Bits) TF0 Interrupt
C/T=0
TR0
GATE(TMOD.3) TH0
Control (8 Bits)
INT0 PIN
T0(P3.4) TL0
(8 Bits) TF0 Interrupt
C/T=0
TR0
TH1
12 12
1.085 s
Crystal frequency 11.0592 10 6
30.38 s
28
1.085 s
1
2 ms
500
TON TOFF T 2 1 ms
s
B83E 1)
(FFFF (18370) 10
12
1.085 10 6
11.0592 10 6
1.085 10 6 18370
25 ms
23041
1.085 10 6
1 12 MHz 12
s.
s
P1
RxD D
(P3.0) SBUF
Shift register CLK (Write only) Q TxD
(P3.1)
CLK
1
12
1 1
32 64
Oscillator frequency
12
K Oscillator frequency
32 12 [(256 TH1)]
K Oscillator frequency
384 Baud rate
Timer 2 overflow rate
16
Oscillator frequency
32 [ 65536 (RCAP2H, RCAP2L)]
Oscillator frequency
32 Baud rate
1 1
32 64
1
32
1
64
k Oscillator frequency
384 Baud rate
1 11.0592 10 6
384 9600
8051
TxD
(P3.1)
To PC
COM Port
RxD
(P3.0)
P 3.0
RxD 3
R1 OUT R1 IN
P 3.1
TxD 2
T1 IN T2 OUT
R2 OUT R2 IN DB-9P
connector
RS 232C
T2 IN T2 OUT
0 IT0
INT0 IE0
1
TF0
0 IT1 Interrupt
INT1 IE1 sources
1
TF1
TI
RI
11.0592 10 6
12
12
12 10 6
TM
R W
R W R W
P1.0 DB0 VCC
P1.1 DB1
20 character 2 line
P1.2 DB2
P1.3 DB3 VEE
LCD
P1.4 DB4
display
P1.5 DB5 module
P1.6 DB6 VSS
P1.7 DB7
8051
RS R/W E
P3.2
P3.3
P3.4
R W
16 2
+5V
R R R R R R R R
K1
K2
K3
8051 K4
Input K5
port
(P1) K6
K7
K8
Column Column Column Column
3 2 1 0
Row 3
Row 2
Row 1
Row 0
+5 V
Column Column Column Column
3 2 1 0
R R R R
Row 3
Row 2
Data Input
bus port A Row 1
Row 0
Output port B
Data bus
5V
8 VCC
19 P17 7
XTAL1 P16
18 6
P15 5 Return
XTAL2 P14 4 lines
P13 3
P12 2
P11 C 8 4 0
1
P10
P 1.0
28
P27
27 D 9 5 1
P26
26
9 P25 P 1.1
RST 25
P24
24
P23 E A 6 2
23
P22
22
8051 P21
21
P 1.2
P20
31 F B 7 3
P07 32
EA/VCC
P06 33 P 1.3
P05 34
10 P04 35
11 RXD 36
TXD P03
P02 37
P01 38
P00 39 P 1.7 P 1.6 P 1.5 P 1.4
13 INT1 PSEN
29 Scan lines
12 INT0 30
ALE
15 T1 16
WR
14 T0 17
RD
+12 V
Stepper
X1 motor
P1.0
7407 X2
Y1 Y2
P1.1 +12 V
7407
P1.2
7407
P1.3
7407
X1
X'1
X2
X'2
+5V
+5V
4.7 K 4.7 K 4.7 K 4.7 K
P 1.0
P 1.1
P 1.2
P 1.3
4 2º 8º
TM
VCC
POT Vin(+) RD P2.5
Vin(–) WR P2.6
ANLGGND
REF/2
D0 P1.0
D1 P1.1
10 K 8051
CLK OUT D2 P1.2
R D3 P1.3
CLK IN D4 P1.4
D5 P1.5
150 pF C CS D6 P1.6
D7 P1.7
GND INTR P2.7
ADC 0803/0804/0805
1
11
. RC
110 s
A1 A8
R 14
R 15 R 14
Output
range control 1 16 Compensation
GND 2 15 –Vref
VEE 3 14 +Vref
A2 6 11 A7
A3 7 10 A6
A4 8 9 A5
MSB LSB
A1 A2 A3 A4 A5 A6 A7 A8
5 6 7 8 9 10 11 12
1 Io
Current switches
Range 4
control
2 GND
R/2R ladder Basic circuit
(+) Vref
13 VCC
14
Reference
15 current
(–) Vref amplifier
16
Compensation
3
VEE
(MSB) 13
A1 2.5 K +5 V
14
Vref
A2 R14
A3 2.5 K
8-bit A4
Rf
digit
input A5 IC 1408 –
4
A6 Io
+ +
A7 Vo
A8
(LSB) 15
16 R15
3 1 2
15 pF 2.5 K
VEE
–15 V
Vref A1 A 2 A 3 A 4 A 5 A 6 A 7 A 8
+ + + + + + +
R 14 2 4 8 16 32 64 128 256
A1 A8
5 1 1 1 1 1 1 1 1
Io
2 . 5 K 2 4 8 16 32 64 128 256
2 mA 255
256
Vo 1 . 992 2 . 5
( 0000 0000) 2
(1111 1111) 2
(1111 1111) 2
VCC
+5 V
5 13 R14
A1 +5 V
14 Vref
6 A2 2.5 K
7
A3 IB If Rf
5K
8-bit 8 A4 RB
1 mA 5K
digital
9 IC 1408
input A5 –
4
10 Io A
A6
+ +
11 A Vo
7
–
12 A
8
15
COMP 16 R15
3 1 2
15 pF 2.5 K
VEE
RB
– IB + Io + If
Io
– IB + Io + If
4 MHz
VCC
X1 X2
C P20
P27
RST L
A0 - A15
P00 A
T
P07 C
R
8051 H
ALE D0 - D 7
PSEN PSEN
RD RD
P10 P17 WR WR
Y1 D A A13
E B A14
C C A15
Y0 O
D
E G1
VCC R
GND G2
+5 V
2.5 K
13 14
2.5 K
2.5 K
DAC
4
–
0808
Vo
+
15
16 3 1 2
2.5 K
VEE
+2.5 V
0V 180º 360º
90º t
FFH
80H
96H
ABH
COH FEH
D2H
–2.5 V
E2H
EFH
F8H
º º º º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
º
+V (4 - 30 V)
LM35 Vout
R1 – Vs
R2 = –––––
50 A
– Vs
º
Current
AD590 to voltage Amplifier Vout
IT converter
VCC
Initialize Ports,
Initialize LCD
Start A/D
conversion
No Is
conversion
over ?
Yes
Read ADC output
Calculate temperature
Is No
temperature
> 100
Make Buzzer ON
Display temperature
on LCD
End
FFFF H FFFF H
60 kbytes
External
64 kbytes
OR External
1000 H
0FFF H
4 kbytes
Internal 0000
0000
VCC
P0 D0
P1
D7
ROM/EPROM
L
8051 A A0
T
C A7
ALE
CLK H Addr.
P3 A8
P2
A15
PSEN OE
ALE
PSEN
PORT 0 INSTR
A0 - A7 A0 - A7
IN
0033 H
002B H
Timer 1 001B H
Interrupt 8 Bytes
Locations External Interrupt 1 0013 H
Timer 0 000B H
RESET 0000 H
Internal Memory
FFFF H
(SFRs)
FF H
Accessible by
Accessible by
Indierct
Upper Addressing
Dierct
128 Addressing 64 kbytes
Only
External
80 H Memory
AND
7F H
Accessible by
Lower Direct and
128 Indierct
Addressing
0000 H
0
D0
P1 P0
D7
VCC
EA RAM
L
A A0
T
A7
C
8051 ALE H
CLK ADDR
P3 P2 PAGE
BITS
RD I/O
WR WR OE
ALE
PSEN
RD
PSEN
WR
2 N 2 12
Input
data
WR
Input buffer EPROM
CS
4096 x 8
Internal decoder
Internal decoder
A10 A11
R/W
Memory
2048 x 8
A0 (N x M) A0
CS
Output buffer Output buffer
RD RD
Output Output
data data
(a) Logic diagram for RAM (b) Logic diagram for EPROM
D0
D7
A0
A7
A8
A15
RD
WR
PSEN
D7 - D0 A9 A8 A7 - A0 OE D7-D0 A9 A8 A7 - A0 OE WR
EPROM (1 K) RAM (1 K)
VCC
CS CS
G
A13 A Y0
A14 B Y1
A15 C B
G1 G2
74LS138
A10
A12 A11
D0 - D7
A0 - A7
A8 - A15
RD
WR
PSEN
EPROM (1 K) RAM (1 K)
CS CS
A15
X1 X2 P2.0
P2.7
VCC L
A
P0.0 T A0-A15
C P0.7 C
RST H
R 8051 D0-D7
PSEN PSEN
EA WR WR
RD RD
ALE ALE
Reset
EPROM 0 EPROM 1
RAM 1
RAM 2
A11
RAM 3 EPROM 0
RAM 4
A14 A Y2
A13 D
B
E
A12 C C Y3 RAM 1
O EPROM 1
D Y4 RAM 2 A11
G1 E
R Y5 RAM 3
G2
GND Y6 RAM 4
X1 X2 P2.0
P2.7
VCC L
A
P0.0 T A0-A15
C P0.7 C
RST H
R 8051 D0-D7
PSEN PSEN
EA WR WR
RD RD
ALE ALE
Reset
EA
TM
FSR reg
RA4/T0CKI
STATUS reg
8
MUX
Power-up
I/O Ports
Timer 8
Instruction Oscillator
Decode & Start-up Timer
Control ALU
Power-on RA3:RA0
Reset
RB0/INT
Interrupt
32 × 8 Unit
Instruction General
Register Purpose
Registers SPI
Unit
Instruction
Indirect Addressing
Decoder Watching
Data Addressing
Timer
ALU
Control Lines
Analog
Comparator
I/O Module 1
Data
SRAM I/O Module 2
I/O Module n
EEPROM
I/O Lines
Cortex-M3
Processor core system
Trace interface
Register
bank
Instruction
Interrupts (NVIC) Decoder Debug
fetch unit Trace
Interrupt system
controller ALU
Memory interface
Memory
Instruction bus protection Data bus
unit
Debug Debug
Bus interconnect
interface
Display menu
1. HEX to BCD
2. BCD to HEX
3. EXIT
Read option
Yes If
option = 3
No
If Yes
option = 1 CALL HTB
?
No
If Yes
option = 2 CALL BTH
?
Stop
(TxC)
(TxC)
( 341B) H
(123A) H
DS 123A0 implied zero
Offset 341B
157BB physical address
Raw
material
Processed
Process
Plant Product
reaction
Feedforward
Means of
Computer quality
Control measurement
action Appropriate
parameter
Reference
Display
Pressure sensor Relays
Flow sensor
Temperature sensor
Data
Input Micro Output D/A
acquisition
ports computer ports converters
system
Load cells
Keyboard Solenoid
PH meters valves
B4 B3
log 16384
log 2 16 K
log 2
(1101 0001 1001 0100) 2
PC 0
PC7
PC 1
12
0.6 s
20 10 6
0.5
0.6 10 6
[1 (255 14)] 0.6 sec
0.5 sec
2.142 10 3
MSB LSB
Gate C/T M1 M0 Gate C/T M1 M0
Timer 1 Timer 0
MSB LSB
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
1 1
100 s
f 10 kHz
100 s
TON TOFF 50 s
2
12
0.6 s
20 10 6
TON 50 s
T of clock 0.6 s
65536 83
Humidity Signal Driver Sound
sensor conditioner circuit alarm
Analog
inputs
Water
Temperature Signal Driver pump
sensor conditioner circuit relay
Port
pins
Microcontroller Data
LCD Module
To
Control
PC MAX Serial
232 interface
RS 232C
connector
Level
converter