1. PPI : 82C55
The 82C55 is a popular interfacing component,
that can interface any TTL-compatible I/O device
to the microprocessor.
It is used to interface to the keyboard and a
parallel printer port in PCs (usually as part of an
integrated chipset).
Requires insertion of wait states if used with a
microprocessor using higher that an 8 MHz clock.
PPI has 24 pins for I/O that are programmable in
groups of 12 pins and has three distinct modes of
operation.
In the PC, an 82C55 or its equivalent is decoded
at I/O ports 60H-63H.
8. Programming 8255
Mode 0:
— Ports A, B, and C can be individually programmed as input or output ports
— Port C is divided into two 4-bit ports which are independent from each other
Mode 1:
— Ports A and B are programmed as input or output ports
— Port C is used for handshaking
PA[7:0] PA[7:0]
PC4 STBA PC7 OBFA
PC5 IBFA PC6 ACKA
PC3 INTRA PC3 INTRA
8255 PB[7:0] 8255 PB[7:0]
PC2 STBB PC2 OBFB
PC1 IBFB PC1 ACKB
PC0 INTRB PC0 INTRB
PC6, 7 PC4, 5
9.
10.
11. Programming 8255
Mode 2:
— Port A is programmed to be bi-directional
— Port C is for handshaking
— Port B can be either input or output in mode 0 or mode 1
PA[7:0]
PC7 OBFA
PC6 ACKA
PC4 STBA
8255 PC5 IBFA
PC3 INTRA
PC0 In Out STBB OBFB
PC0 In Out IBFB ACKB
PC0 In Out INTRB INTRB
PB[7:0]
Mode 0 Mode 1
1. Can you design a decoder for an 8255 chip such that its base address is 40H?
2. Write the instructions that set 8255 into mode 0, port A as input, port B as output,
PC0-PC3 as input, PC4-PC7 as output ?
12. Timing diagram is a combination of the Mode 1 Strobed Input
and Mode 1 Strobed Output Timing diagrams.
13. Example: Mode 1 Input
8255 keyboard
BIT5 EQU 20H
PA0
PORTC EQU 22H
PORTA EQU 20H PA7
READ PROC NEAR
Read: STB
PC4 DAV
• IN AL, PORTC ; read portc
• TEST AL, BIT5 ;test IBF
• JZ Read ;if IBF=0
• IN AL, PORTA ;Read Data
READ ENDP
14. Example: Mode 1 output
8255 Printer
PB0
PB7
ACK Data Strobe : to tell
PC2 ACK the printer to latch the
incoming data.
PC4 DS
Generated Externally
15. Example: Mode 1 output
BIT1 EQU 2 ;send character to printer
PORTC EQU 62H MOV AL, AH ;get data
OUT PORTB, AL ;print
PORTB EQU 61H data
CMD EQU 63H ; send data strobe to
PRINT PROC NEAR printer
; check printer ready? MOV AL, 8 ;clear DS
IN AL, PORTC ;get OBF OUT CMD, AL
TEST AL, BIT1 ;test OBF MOV AL, 9 ;clear DS
JZ PRINT ;if OBF=0 buffer OUT CMD, AL
is full ;rising the data at the
positive edge of DS
RET
PRINT ENDP
20. 8254 Programming
Each counter may be programmed
with a count of 1 to FFFFH.
• Minimum count is 1 all modes except 2
and 3 with minimum count of 2.
Each counter has a program control
word used to select the way the
counter operates.
• If two bytes are programmed, then the
first byte (LSB) stops the count, and the
second byte (MSB) starts the counter
with the new count.
21. 8254 Read Back Command
8254 Read Back Command
1 1 COUNT STATUS CNT2 CNT1 CNT0 0
8254 status word format
NULL
OUTPUT COUNT RW1 RW0 M2 M1 M0 BCD
NULL COUNT: goes low when the new count written to a counter is
actually loaded into the counter
22. 8254 Modes
Mode 0: An events counter enabled with G.
• The output becomes a logic 0 when the control word is
written and remains there until N plus the number of
programmed counts.
Mode 1: One-shot mode.
• The G input triggers the counter to output a 0 pulse for
`count' clocks.
• Counter reloaded if G is pulsed again.
23. 8254 Modes
Mode 2: Counter generates a series of pulses 1 clock pulse
wide.
• The seperation between pulses is determined by the count.
• The cycle is repeated until reprogrammed or G pin set to 0.
• Mode 3: Generates a continuous square-wave with G set to 1.
If count is even, 50% duty cycle otherwise OUT is high 1 cycle
longer.
24. 8254 Modes
Mode 4: Software triggered one-shot
• (G must be 1).
Mode 5: Hardware triggered one-
shot. G controls similar to Mode 1.