Sunteți pe pagina 1din 25

8255

The programmable Peripheral


Interface Device
• The 8255 is a Programmable peripheral
interface device which is used to control
the communication between
microprocessor and i/o devices through
programming using i/o ports.
8255 contains 3 ports named as port A,
port B and port C.

A port is used to communicate between


external i/o device and microprocessor.
The three ports are defined in 3 modes
which are controlled by control word in
control register. The three ports are
combinable into 2 groups
8255
Group A = port A + MSB of port C
Port A
Group B = port B + LSB of port C

MSB of Port c LSB ofport c

Port B
The architecture of

8255
PA7 – PA0

Group A Group A
Control Port A

D0-
D7 Data Bus PC7 – PC4
Buffer Group A
Port C
upper

PC3 – PC0
RD Group B
Port C
AO
Lower
Read/
WR Write
PB7 – PB0
Control Group B
A1 Logic Group B
Control
Port B

CS
CONTROL WORD
Group B
Port CLSB
0 – output
1 – input
Port B
0 – output
1 – input
Mode of
operation
0 - Mode 0
1 - Mode 1
CONTROL WORD
Group A
Port CUSB
0 – output
1 – input
Port A
0 – output
1 – input
Mode of
operation
00 – Mode 0
01 – Mode 1
10 – Mode 2
11 - Nop
CONTROL WORD

1 – i/0 mode
0 – BSR mode
• In i/o mode all the three ports can be
defined as i/p or o/p or bidirectional ports.
In mode 1 and mode 2 ‘Port C’ carries the
handshaking signals.

• In BSR mode the individual bits of ‘port c’


can be enabled or disabled by setting the
three bits (B1,B2 & B3) of control word.
“Hand shaking signals” are used to
control the communication and
synchronize the speed between
microprocessor and external i/o
devices.
Modes of operations of 8255
• 8255 supports three different Modes
mode 0, mode 1 and mode 2.

Mode 0

This is a simple i/o mode and it provides


i/o capability for all the three modes.Any
port can be used as input or output port.
Mode 1
• This mode is called strobed i/o mode. The
hand shaking signals controls i/o action of
the specified port. The Port C lines PC0 –
PC3 provides hand shaking signals for port B
in group B. The Port C lines PC4 – PC7
provides hand shaking signals for port A in
group A.
Mode 1 control word
When Group A is input
PA7 – PA0

PC4 STBA

INTA PC5 IBFA

PC3 INTRA

RD PC6 - PC7 I/O


Mode 1 control word
When Group B is input
PB7 – PB0

PC2 STBA

INTB PC1 IBFB

PC0 INTRA

RD PC6 - PC7 I/O


Mode 1 control word
When Group A is output
PA7 – PA0

PC7 OBFA

INTA PC6 ACKA

PC3 INTRA

WR PC4 – PC5 I/O


Mode 1 control word
When Group B is output
PB7 – PB0

PC1 OBFB

INTB PC2 ACKB

PC0 INTRB
Mode 2
• This is a Strobed bidirectional mode. In
this mode 8-bit port A and 5 bits of port C
(PC3 – PC7) are available.
PC3 INTR

PA0 – PA7
PC7 OBF
INTE1 PC6 ACK

INTE2 PC4 STB


PC5
IBF
WR
RD PC2 – PC0 I/O
BSR MODE
X X X Port C

1 – Set
0 0 0 PC0
0 - Reset
0 0 1 PC1
0 1 0 PC2
0 1 1 PC3
1 0 0 PC4
1 0 1 PC5
1 1 0 PC6
1 1 1 PC7

0 – BSR mode
1 – I/O mode
Checking of the port status
Ex : Write a program to initialize port A and
port C as output to send the data to
external devices and port B as input to
receive the data from input device.
Ans :
3. Define Control word

1 0 0 0 0 0 1 0 = 82 H
2. Designing
A0
PAO – PA7
A1
D0 – D7 8255
PBO – PB7
8086
A15 IO/M
PCO – PC7
A2
CS
A14

To access i/o devices IO/M must be set. CS must be zero to enable the PPI
8255.A0 and A1 are used to select the ports and control registers
3. Identify the Port Addresses and program
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0

1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = 8000H PortA

1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 = 8001H PortB

1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 = 8002H PortC

1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 = 8003H CReg
Program

MOV AL , 82H
MOV DX , 8003 ; Control register
OUT DX , AL ; load control word in control register
MOV AL , DATA
MOV DX , 8000 ; port A
OUT DX , AL ; load a data into port A
MOV DX , 8002 ; port B
OUT DX , AL ; load a data into port B
MOV DX , 8001 ; port B
IN AL , DX ;read data from port B and store in AL
INT 3 ;Vector interrupt for break
Applications of 8255
• Interfacing of Stepper motor
• Interfacing of ADC and DAC
• Interfacing of matrix Key board
• Interfacing of Seven segment LED
• Interfacing of sensors
• Interfacing of various home appliances
and Industrial control elements
Interfacing of stepper motor