3 - General Purpose Programmable Peripheral Devices
3 - General Purpose Programmable Peripheral Devices
Peripheral Devices
The 8255A Programmable Peripheral Interface
The 8255A is a widely used, programmable, parallel I/O device.
It can be programmed to transfer data under various conditions, from simple I/O to interrupt
I/O.
It is flexible, versatile, and economical (when multiple I/O ports are required).
It is an important general-purpose I/O device that can be used with almost any microprocessor.
Block Diagram
Block Diagram
CS Hex
Selection
A7 A6 A5 A4 A3 A2 A1 A0 Address
100000 0 0 80H A
100000 0 1 81H B
100000 1 0 82H C
100000 1 1 83H Control Register
Communication Steps
To communicate with peripherals through the 8255A, three steps are necessary:
1. Determine the addresses of ports A, B, and C and of the control register according to
the Chip Select logic and address lines A0 and A1.
2. Write a control word in the control register.
3. Write I/O instructions to communicate with peripherals through ports A, B, and C.
Operation Modes
Mainly there are two main Modes, BSR Mode, and I/O Mode.
I/O Mode
The I/O mode can be activated by setting D7 to 1, the rest of the control word can specify
the detailed configuration for each port.
Keep in mind that there are 2 Groups and 3 Ports, A,B, and C.
C contains 2 sub Ports, CLower, and CUpper. They are configured differently, but addressed
with the same address
Control Groups
Port B
Group B
CLower
I/O
CUpper
Group A
Port A
Mode 0
Simple Input/output configuration
Example: Mode 0
Given the Following circuit, write a program to input from Port B and Port C L, the output to Port
A and CU
Things we need to do:
Input from B , Output to A
Input from CL , Output to CH
Solution:
Step 1) Configure the Ports Addresses (Memory Addressing)
From the hardware configuration, we know that the port addresses are as following:
A15 A14 A13 A12 A11 A12 A11 A0 A7 A6 A5 A4 A3 A2 A1 A0 Add
Port A 1 X X X X X X X X X X X X X 0 0 8000H
Port B 1 X X X X X X X X X X X X X 0 1 8001H
Port C 1 X X X X X X X X X X X X X 1 0 8002H
CR 1 X X X X X X X X X X X X X 1 1 8003H
A range of addresses can be used, we’ll adopt the following:
Port A = 8000H
Port B = 8001H
Port C = 8002H
Control Register = 8003H
Mode 1
Input or Output with Handshake
Applies to Group A, and Group B
In Mode 1, handshake signals are exchanged between the MPU and peripherals prior to data
transfer. The features of this mode include the following:
Two ports (A and B) function as 8-bit I/O ports. They can be configured either as input or
output ports.
Each port uses three lines from port C as handshake signals. The remaining two lines of
port C can be used for simple I/O functions.
Input and output data are latched.
Interrupt logic is supported.
Note: to enable INTE for Port A, and Port B, we need to access the control Register through the
BSR Mode. It is later discussed
The status word can be read from Port C, we are mostly interested in the IBF Latch at D 5 and D1
which specifies whether data is available
This word is meant only to be Read, other information include interrupt availability and the
status of the Interrupt latch enable INTE
Programming Notes
There are two programming models for operation in Mode 1
Note: to enable INTE for Port A, and Port B, we need to access the control Register through the
BSR Mode. It is later discussed
The status word can be read from Port C, we are mostly interested in the IBF Latch at D 5 and D1
which specifies whether data is available
Example: Mode 1
The following Figure shows an interfacing circuit using the 8255A in Mode 1. Port A is designed
as the input port for a keyboard with interrupt I/O, and port B is designed as the output port for
a printer with status check I/O.