8255
8255
8255
Topics with
Port C (PC0 The It has three individual The 8255 separately canPort Port B -> all ports be A PC7) It is one of programmed(PB0-PB7) or all (PA0-PA7) -> -> Programmable to inputs the accessible all inputs or or Peripheral most A, B,and all inputs outputs orcan ports: beinput or widely be all outputs. Interface(PPI) used output. all outputs. programmed C I/O chips. individually.
A0 and A1 : select the CS (chip select) :specificport with select the 8255. theentire chip
Ports A, B, and of the ports1 : Ports A Any Mode A, C are used forB, CL and CU can be used and B Mode data.Thecan be as input oroutput I/O programmed as ports control input or output. Selecti register control of with handshaking.Mode No is programmed individual 2 : Port A can be bits on ofto select bits are out or (all all used as bits theoperation are in) bidirectional I/O the mode of the 2102440 portwith Introduction to Microprocessors handshaking. 8255three ports A, B, and C.
Mode 0 : simple I/O mode
0 0 0
1 0 0
0 1 0
1 1 0
x x 1
D7 = 0 -> BSR (bit set/reset) mode,the bits of port C are programmedindividua lly.
Operation
ACC ACC
ACCACC [Port][DX]
Register ; send out10 word a indirect: the port from AX to port address is kept by address pointed to the DX register. DX.; The byte from Therefore, it can AL goes to port be as highas 64B1H and byte from FFFFH. ; send out a AH; goes to port word from AX 64B2H Direct: portport to address is addresses 34H specified -35H directly and cannot be larger than FFH. 2102440 Introduction to ; bring a byte Microprocessors into AL from port 99H ; DX = 64B1H
12
; load control reg. address (300H+3 = 303H); load control byte; send it to control register; load PB address; EQU 300Hget the data from PB; load PA address; send it to PA; ; Base address of load PC address; get the bits from PCL; mask the upper 8255 chipEQU 83H ; PA the bits; to upper position bits; shift = out, PB = in, PCL = in, PCU = out
; send it to PCU
Ex. MOV DX, 64B1H OUT 34H, AX OUT DX, AX Ex. IN AL, 99H
MOV DX, B8255C+3MOV AL, CNTLOUT DX, ALMOV DX, B8255C+1IN AL, DXMOV DX, B8255COUT DX, ALMOV DX, B8255C+2IN AL, DXAND AL, 0FHROL AL,1ROL AL,1ROL AL,1ROL AL,1 OUT DX, AL B8255CCNTL
Mnemonic OUT IN
Data transfers can be Byte-wide or word-wide.The accessed I/O port is Input/ selected by an I/Oaddress.The I/O address is specified as part of the Output I/Oinstruction.The 8086 I/O Dataaddresses are output onaddress/data bus lines AD0Transf AD15.The logic levels of signals A02102440 Microprocessors ers and BHEdetermine whether data Introduction to are I/O for an odd-addressed bytewide port, even-addressed bytewide port, or word-wide port.
Ex. Find Ex. Program the 8255 to get data the control word if PAfromport B and send 8255= out, PB it to port A. In addition,data from =in, PC0 Contro = Control is sent out to PC3 word = in, PCL l Word PC4- the PCU. Useport and 1000 addresses of 300Hout. (I) PC7 = 00112 = for the8255 83H3003H chip.
11
14
3. The LCDs 2. The LCDs R/W pin is RS pin is 4. The LCDs E connected 1. The LCDs pin is to connected to data pins PB1 connected to are of Port B PB0 of Port B of the 8255. connected to PB2 of Port B of the 8255. Port A of the of the 8255. Ports A 5. Both 8255. and B are configured as output ports.
2102440 Introduction to Microprocessors
16
QSDELAY PROC NEAR MOV CX,16572 ;16,572x15.085 usec=1/4 sec usec=1/4 PUSH AX W1: IN AL,61HAND AL,00010000BCMP AL,AHJE Ex. Show the W1MOV AH,ALLOOP W1POP AXRET address decoding where port QSDELAY ENDP
13
I/O 300H, then write a program to toggle all bits of PA continuously with a seconddelay. Use INT 16H to exit if there is a keypress.keypress.
15
MOV DX,303H ;CONTROL REG ADDRESSMOV AL,80H ;ALL PORTS AS OUTPUTOUT DX,AL AGAIN: MOV DX,300HMOV AL,55HOUT DX,ALCALL QSDELAY ; 1/4 SEC DELAYMOV AL,0AAH ;TOGGLE BITOUT DX,ALCALL QSDELAYMOV AH,01INT 16H ;CHECK KEYPRESSJZ AGAIN ;PRESS ANY KEY TO EXITMOV AH,4CHINT 21H ;EXIT