The 8255 Programmable Peripheral Interface
3 8-bit IO ports PA, PB, PC PA can be set for Modes 0, 1, 2. PB for 0,1 and PC for mode 0 and for BSR. Modes 1 and 2 are interrupt driven. PC has 2 4-bit parts: PC upper (PCU) and PC lower (PCL), each can be set independently for I or O. Each PC bit can be set/reset individually in BSR mode. PA and PCU are Group A (GA) and PB and PCL are Group B (GB) Address/data bus must be externally demux'd. TTL compatible. Improved dc driving capability
8255 Block diagram
D0 - D7 These are the data input/output lines for the device D0 - D7 These are the data input/output lines for the device. All information read from and written to the 8255 occurs via these 8 data lines. CS (Chip Select Input). If this line is a logical 0, the microprocessor can read and write to the 8255. RD (Read Input) Whenever this input line is a logical 0 and the RD input is a logical 0, the 8255 data outputs are enabled onto the system data bus. WR (Write Input) Whenever this input line is a logical 0 and the CS input is a logical 0, data is written to the 8255 from the system data bus A0 - A1 (Address Inputs) The logical combination of these two input lines determines which internal register of the 8255 data is written to or read from. RESET The 8255 is placed into its reset state if this input line is a logical 1. All peripheral ports are set to the input mode. PA0 - PA7, PB0 - PB7, PC0 - PC7 These signal lines are used as 8-bit I/O ports. They can be connected to peripheral devices. The 8255 has three 8 bit I/O ports and each one can be connected to the physical lines of an external device. These lines are labeled PA0-PA7, PB0-PB7, and PC0-PC7. The groups of the signals are divided into three different I/O ports labeled port A (PA), port B (PB), and port C (PC).
8255 programming & operation Bit D7 of the control register specifies either I/O function or the Bit Set/Reset function. 8255 has three operation modes: mode 0, mode 1, and mode2.
8255 programming & operation Mode 0: ( I/O mode) Ports A, B, and C can be individually programmed as input or output ports. Port C is divided into two 4-bit ports which are independent from each other. Mode 1:( Strobed I/O) Ports A and B are programmed as input or output ports. Port C is used for handshaking. Port A -Input: PC3 PC4 PC5 – control PC6 PC7 – I/O Port A -output: PC3 PC6 PC7 – control PC4 PC5– I/O Port B input /output: PC0 PC1 PC2– control mode1/mode2
Mode 0: Simple Input or Output In this mode, ports A, B are used as two simple 8-bit I/O ports and port C as two 4-bit ports. Each port can be programmed to function as simply an input port or an output port. The input/output features in Mode 0 are as follows. 1. Outputs are latched. 2. Inputs are not latched. 3. Ports don’t have handshake or interrupt capability.
Mode 1: strobed Input or Output with Handshake In this mode, handshake signals are exchanged between the MPU and peripherals prior to data transfer. The features of the mode include the following: 1. Two ports (A and B) function as 8-bit I/O ports. They can be configured as either as input or output ports. 2. Each port uses three lines from ort C as handshake signals. The remaining two lines of Port C can be used for simple I/O operations. 3. Input and Output data are latched. 4. Interrupt logic is supported.
Mode 2: Bidirectional Data Transfer with handshaking This mode is used primarily in applications such as data transfer between two computers. In this mode, Port A can be configured as the bidirectional port and Port B either in Mode 0 or Mode 1. Port A uses five signals from Port C as handshake signals for data transfer. The remaining three signals from port C can be used either as simple I/O or as handshake for port B. BSR (Bit Set/Reset) Mode The BSR mode is concerned only with the eight bits of port C, which can be set or reset by writing an appropriate control word in the control register. A control word with bit D7 =0 is recognized as a BSR control word, and it does not alter any previously transmitted control word with bit D7=1; thus the I/O operations of ports A and B are not affected by a BSR control word. In BSR mode, individual bits of port C can be used for applications such as an on/off switch. Ports A and B are not affected by the BSR Mode.
8255 programming & operation Mode2:(Strobed Bidirectional bus I/O) Port A is programmed to be bi-directional. Port C is for handshaking. Port B can be either input or output in mode 0 or mode 1. D7 D6 D5 D4 D3 D2 D1 D0 1 X 1/0 Mode2 for PortA PortB I/O PC0-PC2 I/O I/O mode mode for portB
Write a program to initialize 8255 in Mode 0 in the configuration given below: 1. Port A: Simple input 2. Port B: Simple output 3. Port CL: Output 4. Port Cu: Input Assume address of the control word register of 8255 as 83H.
Write a program to initialize 8255 in Mode 1 in the configuration given below: 1. Port A: Output with handshake 2. Port B: Input with handshake 3. Port CL: Output 4. Port Cu: Input Assume address of the control word register of 8255 as 23H.
Interfacing of 8255