The 8255 Programmable Peripheral Interface chip

The following paragraphs summarise the main features of the 8255, which should be enough for most applications. More complex applications require the full data sheet.

The 8255 has three 8-bit ports (A, B and C) which may be used in three modes. Modes 2 and 3 use certain port C lines for handshaking. Mode 0 is easy to use for most applications.

The 8255 appears as four registers

Address Offset Function
B000 +00 Port A
  +01 Port B
  +02 Port C
  +03 Control

In mode 0, ports A and B may be set up as 8 input lines or 8 output lines.
Port C is divided into upper and lower 4-bit sections, each of which may be set up for input or output.

B003 7 6 5 4 3 2 1 0 Bit function
                0 Port C lower = output
                1 Port C lower = input
              0   Port B = output
              1   Port B = input
            0     Mode 0
            1     Mode 1
          0       Port C upper = output
          1       Port C upper = input
        0         Port A = output
        1         Port A = input
    0 0           Mode 0: Basic input/output
    0 1           Mode 1: Strobed Input/output
    1 x           Mode 2: Bi-directional Bus
  0               Mode select flag = inactive
  1               Mode select flag = active

Thus to set port A for output, port B for input, port C lower for output and port C upper for input (the normal conditions in the Atom), we have to write 10001010 binary (8A hex) to B003. We can then read the data on port B at B001.

Port C lines can also be changed individually (if set for output) by writing to the control register a value equal to 2*BitNumber +Q where Q is the value of the output.

When set for output, the 24 I/O lines can each drive one TTL load, sinking 1.7 mA at 0.4V, sourcing 200 mA at 2.4V. As inputs, they present a high impedance to the driving source, recognising voltages below 0.8V as '0' and voltages between 2.0V and 5V as '1'