82C55
Programmable
Peripheral Interface
PPI
3
82C55 programmable peripheral interface
a popular, low-cost interface component found in many
applications.
The PPI has 24 pins for I/O, programmable in groups of 12 pins and
groups that operate in three distinct modes of operation.
82C55 can interface any TTL-compatible I/O device to the
microprocessor.
The 82C55 (CMOS version) requires wait states if operated with a
processor using higher than an 8 MHz clock.
4
82C55 programmable peripheral interface
Because I/O devices are inherently slow, wait states used during
I/O transfers do not impact significantly upon the speed of the
system.
The 82C55 still finds application even in the latest Core2-based
computer system.
An experimentation board is available that plugs into the parallel
port of a PC, to allow access to an 8255 located on the board.
o The 8255 is programmed in either assembly language or Visual
C++ through drivers available with the board.
5
82C55 programmable peripheral interface
82C55 is used for interface to IO devices in many PCs.
o found as a function within an interfacing chip set
o 82C55 is interfaced to keyboard control at port addresses
60H–63H.
o also for controlling the speaker, timer, and other internal
devices such as memory expansion
o It is also used for the parallel printer port at I/O ports 378H–
37BH.
6
82C55 programmable peripheral interface
Basic Description of the 82C55
o The three I/O ports (labeled A, B, and
C) are programmed as groups.
o group A connections consist of port A
(PA7–PA0) and the upper half of port C
(PC7–PC4)
o group B consists of port B (PB7–PB0)
and the lower half of port C (PC3–PC0)
o 82C55 is selected by its CS pin for
programming and reading/writing to a
port. 7
82C55 programmable peripheral interface
Basic Description of the 82C55
o In the PC, a pair of 82C55s, or equivalents, are decoded at I/O
ports 60H–63H and also at ports 378H–37BH.
o For 82C55 to be read or written, the CS input must be logic 0
and the correct I/O address must be applied to the A1 and A0
pins.
8
82C55 programmable peripheral interface
Basic Description of the 82C55
9
82C55 programmable peripheral interface
Basic Description of the 82C55
o it functions at 8-bit addresses C0H (port A), C2H (port B), C4H
(port C), and C6H (command register).
o All 82C55 pins are direct connections to the X86, except the
CS pin. The pin is decoded/selected by a 74ALS138 decoder.
o A RESET to 82C55 sets up all ports as simple input ports using
mode 0 operation.
o initializes the device when the processor is reset
o After a RESET, no other commands are needed, as long as it is
used as an input device for all three ports.
10
82C55 programmable peripheral interface
Programming the 82C55
11
82C55 programmable peripheral interface
Programming the 82C55
o 82C55 is programmed through two internal command
registers.
o Bit position 7 selects either command byte A or command
byte B.
o command byte A programs functions of group A and B
o command byte B sets (1) or resets (0) bits of port C only if
the 82C55 is programmed in mode 1 or 2
o Group B (port B and the lower part of port C) are programmed
as input or output pins.
12
82C55 programmable peripheral interface
Programming the 82C55
o Group B operates in mode 0 or mode 1
o Mode 0 is basic input/output mode that allows the pins of
group B to be programmed as simple input and latched
output connections
o buffered input device
o latched output device
o Mode 1 operation is the strobed operation for group B
connections
o data are transferred through port B
o handshaking signals are provided by port C
13
82C55 programmable peripheral interface
Programming the 82C55
o Group A (port A and the upper part of port C) are
programmed as input or output pins.
o Group A can operate in modes 0, 1, and 2.
o mode 2 operation is a bidirectional mode of operation for
port A
o If a 0 is placed in bit position 7 of the command byte,
command byte B is selected
o This allows any bit of port C to be set (1) or reset (0), if the
82C55 is operated in either mode 1 or 2.
o otherwise, this byte is not used for programming
14
82C55 programmable peripheral interface
Programming the 82C55: Mode 0 Operation
o Example 1: 82C55 connected to a set of eight seven-segment
LED displays. (standard LEDs)
o ports A & B are programmed as (mode 0)
o port A provides segment data inputs port B provides a
means of selecting one display position at a time for
multiplexing the displays
o Ports A and B are programmed as simple latched output
ports.
15
82C55 programmable peripheral interface
Programming the 82C55: Mode 0 Operation
Example 1
Address
Decoder
700H
16
82C55 programmable peripheral interface
Programming the 82C55: Mode 0 Operation
o Example 1 : 82C55 connected to a set of eight seven-segment
17
82C55 programmable peripheral interface
Programming the 82C55: Mode 0 Operation
o Example 2 : 82C55 connected to a Stepper Motor
o Another device often interfaced to a computer system is
the stepper motor.
o a digital motor because it is moved in discrete steps as
it traverses through 360°
o An inexpensive stepper motor is geared to move perhaps
15° per step. A more costly, high-precision stepper motor
can be geared to 1° per step.
o In all cases, these steps are gained through many
magnetic poles and/or gearing.
18
82C55 programmable peripheral interface
Programming the 82C55: Mode 0 Operation
o Example 2 : 82C55 connected to a Stepper Motor
o Two coils are energized at a time, causing the motor to
step at 45°, 135°, 225°, and 315°.
o The motor is shown with the armature rotated to four
discrete places, called full stepping.
o accomplished by energizing the coils, as shown
19
82C55 programmable peripheral interface
Programming the 82C55: Mode 0 Operation
o Example: 82C55 connected to a Stepper Motor
20
82C55 programmable peripheral interface
Programming the 82C55: Mode 0 Operation
o Example: 82C55 connected to a Stepper Motor
o The motor is driven by NPN Darlington amp pairs to
provide a large current to each coil.
o This circuit uses the 82C55 to provide drive signals used to
rotate the motor armature in either the right- or left-hand
direction.
21
82C55 programmable peripheral interface
Programming the 82C55: Mode 0 Operation
o Example: 82C55 connected to a Stepper Motor
22
82C55 programmable peripheral interface
Programming the 82C55: Mode 0 Operation
o Example 3 : 82C55 connected to a Key Matrix
o a key matrix with 16 switches interfaced to ports A and B
of an 82C55.
o The keys are organized into four rows and columns:
(ROW0–ROW3) (COL0–COL3)
o port A is programmed as an input port to read the rows
o port B is programmed as an output port to select a
column
23
82C55 programmable peripheral interface
Programming the 82C55: Mode 0 Operation
o Example 3 : 82C55 connected to a Key Matrix
Address
Decoder
Code is reading
assignment
24
82C55 programmable peripheral interface
Programming the 82C55: Mode 1 Strobed Input
o Causes port A and/or port B to function as latching input
devices.
o allows external data to be stored to the port until the
microprocessor is ready to retrieve it
o Port C is used in mode 1 operation—not for data, but for
control or handshaking signals.
o to help operate either or both port A and B as strobed
input ports
25
82C55 programmable peripheral interface
Programming the 82C55: Mode 1 Strobed Input
general-purpose I/O pins
26
82C55 programmable peripheral interface
Programming the 82C55: Mode 1 Strobed Input
o STB: The strobe input loads data to the port latch, which
holds the information until it is input to the microprocessor
via the IN instruction.
o IBF: Input buffer full is an output indicating that the input
latch contains information.
o INTR: Interrupt request is an output that requests an
interrupt. The INTR pin becomes a logic 1 when STB returns to
a logic 1. Cleared when data are input from the port by the
processor.
o INTE: Interrupt enable signal is neither input nor output; it is
an internal bit programmed via port PC4 (port A) or PC2 (port
B) bit position. 27
82C55 programmable peripheral interface
Programming the 82C55: Mode 1 Strobed Input
o An example of a strobed input device is a keyboard.
o The keyboard encoder de-bounces the key switches and
provides a strobe signal whenever a key is depressed.
o the data output contains ASCII-coded key code
28
82C55 programmable peripheral interface
Programming the 82C55: Mode 1 Strobed Output
o Strobed output operation is similar to mode 0 output
operation.
o except control signals are included to provide handshaking
o When data are written to a strobed output port, the output
buffer full signal becomes logic 0 to indicate data are present
in the port latch.
29
82C55 programmable peripheral interface
Programming the 82C55: Mode 1 Strobed Output
30
82C55 programmable peripheral interface
Programming the 82C55: Mode 1 Strobed Output
o OBF: Output buffer full goes low whenever data are output
(OUT) to the port A or B latch. The signal is set to logic 1 when
the ACK pulse returns from the external device.
o ACK: The acknowledge signal causes the OBF pin to return to
logic 1. The ACK signal is a response from an external device,
indicating that it has received data from the 82C55 port.
o INTR: Interrupt request often interrupts the processor when
the external device receives the data via the ACK signal.
Qualified by the internal INTE (interrupt enable) bit.
o INTE: Interrupt enable is neither input nor output; it is an
internal bit programmed to enable or disable the INTR pin.
INTE A is programmed using PC6 bit. INTE B is programmed
using the PC2 bit.
31
82C55 programmable peripheral interface
Programming the 82C55: Mode 1 Strobed Output
o Example: The printer interface demonstrates how to achieve
strobed output synchronization between the printer and the
82C55.
32
82C55 programmable peripheral interface
Programming the 82C55: Mode 2 Bidirectional Operation
o Mode 2 is allowed with group A only.
o Port A becomes bidirectional, allowing data transmit/receive
over the same eight wires.
o useful when interfacing two computers
o Also used for IEEE-488 parallel high-speed GPIB (general-
purpose instrumentation bus) interface standard.
o The bidirectional bus is used by referencing port A with the IN
and OUT instructions.
33
82C55 programmable peripheral interface
Programming the 82C55: Mode 2 Bidirectional Operation
o The state of the INTR pin is controlled through port C bits PC6
(INTE1) and PC4 (INTE2).
34
82C55 programmable peripheral interface
Programming the 82C55: Mode 2 Bidirectional Operation
o To transmit data through the bidirectional bus, the program
first tests to determine whether the output buffer is empty.
o if so, data are sent to the output buffer via OUT
o The external circuitry also monitors the signal to decide
whether the microprocessor has sent data to the bus.
o To receive data through the bidirectional port A bus, IBF is
tested with software to decide whether data have been
strobed into the port.
o if IBF = 1, data is input using IN
35
82C55 programmable peripheral interface
Programming the 82C55: Mode 2 Bidirectional Operation
o The external interface sends data to the port by using the STB
signal.
o the IBF signal becomes logic 1 and data at port A are held
inside the port in a latch
o When the IN executes, the IBF bit is cleared and data in the
port are moved into AL.
o The INTR (interrupt request) pin can be activated from both
directions of data flow through the bus.
o If INTR is enabled by both INTE bits, the output and input
buffers both cause interrupt requests.
o This occurs when data are strobed into the buffer using STB or
when data are written using OUT. 36
82C55 programmable peripheral interface
Programming the 82C55: Mode 2 Bidirectional Operation
37
82C55 programmable peripheral interface
Programming the 82C55: Mode 2 Bidirectional Operation
38
82C55 programmable peripheral interface
Programming the 82C55: Mode Summary
39