You are on page 1of 4

2

Topics with

Interfacing 8086/8088T hree modes of operation

Status wordInterfacing with 8086 data busApplications

2102440 Introduction to Microprocessors

Block Diagra m of the 8255

2102440 Introduction to Microprocessors

Mode 0Mode 1Mode 2

9 2102440 8255 8-bit Introducti Programmabl e on to Micropr Peripheral ocessors Interface

Suree 1 Pumrin, Chapter Ph.D.

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.

8255 PPI Chip

CU: CL : lower upper bits (PC4bits (PC0PC7) PC3)


2102440 Introduction to Microprocessors

A0 and A1 : select the CS (chip select) :specificport with select the 8255. theentire chip

8255 Port Selecti on

2102440 Introduction to Microprocessors

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

8255 is not selected Control register CS A1 A0 Port C PortPort B A Selects

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.

I/O Mode of the 8255

2102440 Introduction to Microprocessors

Addre ssing 8255

2102440 Introduction to Microprocessors

Input/ Output Instruc tions

[Port] ; ACC = AL or AX[DX]

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

8255 Examp le code (I)

; 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

2102440 Introduction to Microprocessors

OUT Port, ACCOUT DX, IN ACC, PortIN ACC ACC, DX Format

; send it to PCU

Output directOutput Input directInput indirect(variable) indirect(variable) Meaning

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

2102440 Introduction to Microprocessors

14

8255 Conne ction to LCD

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

8-bit Analog to Digital Conve rter

16

2102440 Introduction to Microprocessors

8255 Examp le Code (II)

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

A of the 8255 has an I/O address of

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.

2102440 Introduction to Microprocessors

8255 Conne ction to Steppe r Motor

15

2102440 Introduction to Microprocessors

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

You might also like