Interfacing 8255 PPI and 8253 Timer With easy examples.
The 8255 Programmable Peripheral Interface (PPI) and 8253 Programmable Interval Timer are the classic support chips that connect an 8085 or 8086 to the outside world. The 8255 provides 24 programmable digital I/O lines for keyboards, printers and switches; the 8253 provides three independent 16-bit counters for delays, baud rates and square waves. Together they turn a bare CPU into a useful controller.
They matter because they teach the universal interfacing pattern: write a control word to configure, then use data registers. The same configure-then-use idea appears in every modern microcontroller peripheral, from GPIO to UART to timers.
Key Concepts
- 8255 ports: three 8-bit ports — A, B, C — plus a control register (A1–A0 select). Port C splits into upper/lower 4-bit nibbles for handshake lines.
- 8255 modes: Mode 0 (plain input/output per port), Mode 1 (strobed I/O with handshaking), Mode 2 (bidirectional bus, port A only).
- 8255 control word: D7 = 1 selects mode-set; D6–D5 = port A mode, D4 = port A direction, D3 = port C upper direction, D2 = port B mode, D1 = port B direction, D0 = port C lower direction (1 = input, 0 = output).
- 8253 counters: three 16-bit down-counters (0, 1, 2), each with clock, gate and output pins, set via one control register.
- 8253 modes 0–5: interrupt on terminal count, retriggerable one-shot, rate generator, square wave, software strobe, hardware strobe.
- 8253 control word: SC1–SC0 = counter select, RW1–RW0 = byte order (LSB/MSB/LSB-then-MSB), M2–M0 = mode, BCD = binary/BCD counting.
Formulas
The 8253's core formula: fout = fclk / N, where N is the loaded 16-bit count (1–65,536); Mode 3 gives a symmetric square wave for even N. The 8255's "formula" is its control-word bit pattern: Mode 0 with all ports output is 1 00 0 0 0 0 0 = 80H. Flip direction bits to 1 for inputs — e.g. port A output, port B input, port C output in Mode 0 gives 1 00 0 0 0 1 0 = 82H.
Worked Example
Generate 1 kHz from 1 MHz (8253 counter 0, Mode 3); set the 8255 all-output. N = 1,000,000/1,000 = 1000 = 03E8H. Control word = 00 (counter 0) + 11 (LSB-then-MSB) + 011 (Mode 3) + 0 (binary) = 36H. OUT 36H to control, then OUT E8H and OUT 03H to counter 0. OUT 80H configures the 8255. Five OUT instructions yield a clean 1 kHz wave plus 24 output lines.
Common Misconceptions
- "Port C's data address sets the control word." No — the control register is a separate address (A1–A0 = 11). Port C writes only change pin levels.
- "The 8253 counts up to the loaded value." It counts down to zero, then reloads (modes 2, 3) or stops (modes 0, 1, 4, 5).
- "Bit Set/Reset works on any port." BSR mode (control word D7 = 0) touches only port C bits, one at a time.
Real-World Applications
- Printer ports: the Centronics parallel port used an 8255 in Mode 1 strobed output.
- Keyboards: rows driven from one port, columns read on another — the classic matrix scan.
- Baud rates: an 8253 divides a master clock down to UART rates like 9600.
- Industrial timing: delays, event counting and frequency measurement in 8085 controllers.
The 8255/8253 embody configure-then-use: load a control word, then move data or divide clocks. Do it by hand once, and every modern peripheral datasheet reads like a familiar variation.