8255 PPI
Programmable Peripheral Interface, modes.
In 8086-based microprocessor systems, the CPU cannot directly interface with most peripheral devices due to differences in signal levels, data formats, and timing. The 8255 Programmable Peripheral Interface (PPI) is a dedicated IO chip that acts as a configurable bridge between the 8086 CPU and external peripherals. It is programmable, meaning its operating mode can be changed by writing a control word to it, making it suitable for a wide range of interfacing applications.
Core Concept Explanation
The 8255 PPI contains three 8-bit IO ports named Port A, Port B, and Port C. Port C is further divided into an upper nibble (PC7-PC4, called CU) and a lower nibble (PC3-PC0, called CL). These ports are internally organized into two groups: Group A (Port A + Port CU) and Group B (Port B + Port CL). Each group can be independently programmed to operate in a specific mode.
The 8255 connects to the 8086 data bus (D7-D0) and responds to read and write operations using its RD and WR pins. The CS (Chip Select) pin is driven low by the address decoder when the CPU accesses the 8255. Two address pins A1 and A0 select which internal register is accessed: A1A0 = 00 selects Port A, 01 selects Port B, 10 selects Port C, and 11 selects the Control Word Register.
Before the 8255 can be used, a control word must be written to the control register. This control word is an 8-bit value that specifies the operating mode for each group and the direction (input or output) of each port. Once the control word is written, the 8255 configures its internal logic accordingly and begins operating in the specified mode.
Operating Modes of 8255
Mode 0: Basic IO
In Mode 0 (Basic Input/Output), each port (A, B, CU, CL) can be independently configured as either input or output. There is no handshaking. The CPU simply reads from or writes to the port, and the peripheral must be ready. Mode 0 is the simplest and most common mode, used when timing is not critical or when the peripheral is always ready.
Mode 1: Strobed IO
In Mode 1 (Strobed Input/Output), Port A or Port B operates as either input or output with handshaking signals provided by Port C pins. For Group A in Mode 1 input, Port C provides STB (strobe) and IBF (input buffer full) signals. For output, it provides OBF (output buffer full) and ACK (acknowledge) signals. This mode allows synchronized data transfer with peripherals that need handshaking.
Mode 2: Bidirectional IO
In Mode 2 (Bidirectional Bus IO), only Port A supports this mode. Port A becomes a bidirectional 8-bit bus, and Port C pins (PC3-PC7) are used for associated handshaking signals. Mode 2 is used when the same port must alternately act as input and output, such as in bus-sharing applications. Group B remains in Mode 0 or Mode 1 when Group A is in Mode 2.
Control Word Format
The 8255 control word for Mode Set operation has bit 7 (D7) always set to 1 to distinguish it from BSR (Bit Set/Reset) operations. The format of the control word is: D7 = 1, D6-D5 = Mode for Group A (00 = Mode 0, 01 = Mode 1, 1x = Mode 2), D4 = Port A direction (1 = input, 0 = output), D3 = Port CU direction (1 = input, 0 = output), D2 = Mode for Group B (0 = Mode 0, 1 = Mode 1), D1 = Port B direction, D0 = Port CL direction.
Port C also supports Bit Set/Reset (BSR) mode, where individual bits of Port C can be set or reset by writing a special control word with D7 = 0. This is very useful for controlling individual output lines such as LEDs or relay signals without affecting other bits of Port C.
Mathematical Expression
The 8255 occupies four consecutive IO port addresses (one for each port and one for the control register). If the base address of the 8255 is PORT_BASE, then: Port A = PORT_BASE, Port B = PORT_BASE + 1, Port C = PORT_BASE + 2, Control Register = PORT_BASE + 3. The address decoder generates CS when the address matches PORT_BASE and ignores the lowest 2 bits (A1, A0), which are connected directly to the 8255 to select the internal register.
Practical Understanding
A common application of the 8255 is connecting an 8086 system to a matrix keyboard and a 7-segment display simultaneously. Port A can be programmed as output to drive the display, while Port B is programmed as input to read the keyboard. Mode 0 is sufficient for this because neither device requires handshaking.
For printer interfacing, Mode 1 is preferred because printers use strobe and acknowledge signals to coordinate data transfer. The CPU writes data to Port A, asserts OBF, and waits for ACK from the printer before sending the next byte. Port C pins handle these handshaking signals automatically in Mode 1.
Solved Example
An 8255 is interfaced with an 8086 system with base address 60H. Program it so that Port A is in Mode 0 output, Port B is in Mode 0 input, Port CU is output, and Port CL is input. Calculate and write the control word.
Given:
Base address of 8255 = 60H
Port A = Mode 0, Output → D4 = 0
Port B = Mode 0, Input → D1 = 1
Port CU = Output → D3 = 0
Port CL = Input → D0 = 1
Why this formula applies:
Control word format (Mode Set, D7=1):
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 0 0 0 1 1
Formula:
Control Word = 10000011B = 83H
Substitution:
D7 = 1 (Mode Set Flag)
D6 D5 = 00 (Group A = Mode 0)
D4 = 0 (Port A = Output)
D3 = 0 (Port CU = Output)
D2 = 0 (Group B = Mode 0)
D1 = 1 (Port B = Input)
D0 = 1 (Port CL = Input)
Calculation:
1 0 0 0 0 0 1 1 = 83H
8086 Assembly to initialize:
MOV AL, 83H
OUT 63H, AL ; Write control word to Control Register (base+3 = 60H+3 = 63H)
Final Answer: Control Word = 83H, written to port address 63HExam Tip: In GATE, control word calculation is a very common question. Remember: D7 = 1 for Mode Set operation, D7 = 0 for BSR mode. Also, Port A can operate in Mode 0, 1, or 2. Port B can only operate in Mode 0 or Mode 1. Mode 2 is exclusive to Group A (Port A only).
Quick Revision
- 8255 PPI: 3 ports — Port A (8-bit), Port B (8-bit), Port C (split: CU 4-bit + CL 4-bit). Total 24 IO lines.
- Group A = Port A + CU. Group B = Port B + CL. Each group configured independently.
- A1 A0 select: 00 = Port A, 01 = Port B, 10 = Port C, 11 = Control Register.
- Mode 0: Basic IO, no handshaking. Mode 1: Strobed IO with handshaking via Port C. Mode 2: Bidirectional (Port A only).
- Control word D7 = 1 for Mode Set. D7 = 0 for Bit Set/Reset (BSR) on Port C individual bits.
- Control word = 83H means: Mode 0 for both groups, Port A output, Port B input, CU output, CL input.
- Control register address = Base + 3. Port A = Base, Port B = Base+1, Port C = Base+2.
Loading lab...
8255 PPI Quiz
Test your command over 8255 PPI operating modes, control word format, and port configurations.
Q1.What is the control word written to the 8255 to configure Port A as Mode 1 input, Port B as Mode 0 output, and Port C upper and lower as output?
Related Articles
7 Segment Display Interface
Multiplexing display using 8255.
6 min read
Keyboard Interfacing
Matrix keyboard scanning rows/cols.
7 min read
Memory Interfacing
Address decoding, EPROM/RAM connection.
4 min read
Stepper Motor Interface
Driving coils sequence.
10 min read
8237 DMA
Direct Memory Access controller operation.
8 min read