8255 Ppi
8255 Ppi
I/O
• Any microprocessor need to be interfaced with I/O
devices.
• The I/O address is 16 bit.
Memory mapped I/O
I/O Map
Parallel Printer Interface example
Peripheral Controllers
• Intel has developed several peripheral controller chips
designed to support its processors.
• The goal is to give a complete I/O interface in one chip.
• Examples:
• 8255 is Programmable Peripheral Interface (PPI).
• 8259 is Programmable Interrupt Controller (PIC)
• 8253/8254 is Programmable Interval Timer (PIT)
• 8237 is Programmable DMA controller.
8255A
• Is one of the peripheral controller chips designed to
support its processors.
• 8255 is Programmable Peripheral Interface (PPI).
• It is a general purpose parallel I/O Interfacing
device.
• It provides 24 I/O lines organized in three 8-bit I/O
ports in one 40-pin package.
• The ports are usually labeled A,B, and C.
fig 8.11
FIGURE 8-11 8255 programmable peripheral interface (PPI). Twenty-four I/O pins are provided grouped as three 8-bit I/O ports. There is
one 8-bit control port. (Courtesy of Intel Corporation.)
Size of ports
• Ports A and B can be programmed as an 8-bit input
or output port.
• In port C each nibble (four bits) can be programmed
separately to be a 4-bit input or output port.
• Only the above size of ports (byte or nibble) can be
programmed. For Example, individual bit in a port
cannot be programmed.
• However, what make 8254 a versatile devise is its
programming modes
Programming modes
• Mode 0: the 8255A is programmed to look like
three simple I/O ports.
• Mode 1: the 8255A is programmed to have two
handshaking I/O ports.
• Mode 1: the 8255A is programmed to have one
bidirectional port with five handshaking signals.
• The modes can be intermixed, for example, port A
is programmed to operate in mode 2, while port B
operates in mode 0.
• bit set/reset mode allows individual bits of port C to
be set or reset for control purposes.
FIGURE 8-12 Interfacing the 8255 to the 386/486 processors. The four PPI ports are mapped to addresses 0, 4, 8, and C.
8255
A1 A0 RD WR CS Direction
0 0 0 1 0 PORT A to data bus
0 1 0 1 0 PORT B to data bus
1 0 0 1 0 PORT C to data bus
20
• This program displays 5 hexadecimal digits on the 7-
segment LED display units connected to the 8255 PPI
• .DATA
• MSG DB 0EH,0EH,4,1,1
• ;------ code segment ------
• .CODE
• MAIN: MOV AX,@DATA
• MOV DS,AX
• MOV DX,303H
• MOV AL,10000000B
• OUT DX,AL
• START: MOV SI,OFFSET MSG
• MOV DI,0
• MOV BL,00010000B
21
• NEXT: MOV BH,[SI+DI]
• CALL DISPLAY ;CALL THE DISPLAY SUBROUTINE
• SHR BL,1
• INC DI
• CMP DI,4
• JNE NEXT
• JMP START
• DISPLAY: MOV DX,300H ;DISPLAY SUBROUTINE
• MOV AL,BL
• OUT DX,AL
• MOV DX,301H
• MOV AL,BH
• OUT DX,AL
• RET
• END MAIN
22
Application 2: Keyboard Control
23
• This program reads a keystroke from the 64-key keyboard connected to the PPI
• .DATA
• LETTERS DB
‘0123456789ABCDEFGHIJKLMNOPRSTUVWXYZabcdefghijklmnopqrstuv
wxyz.?’
• ;------ code segment ------
• .CODE
• MAIN: MOV AX,@DATA
• MOV DS,AX
• MOV DX,303H
• MOV AL,10000010B
• OUT DX,AL
• MOV BL,11111110B
24
• SCAN: ROR BL
• MOV AL,BL
• MOV DX,300H
• OUT DX,AL
• CMP AL,11111111B
• JE SCAN
• PUSH BX
• MOV DI,0
• NEXT: SHL BL,1
• JNC FINISHC
• INC DI
• JMP NEXT
25
• FINISHC: SHL AL,1
• JNC FINISHR
• ADD DI,8
• JMP NEXT
• FINISHR: MOV SI,OFFSET LETTERS
• MOV DL,[SI+DI]
• MOV AH,2
• INT 21H
• POP BX
• JMP SCAN
• END MAIN
26