Digital I/O Programming Using PPI
Digital I/O Programming Using PPI
1
Electrical Engineering Department, College of Engineering, Qassim University, Buraidah,
Saudi Arabia, Microprocessor Laboratory (EE354)
LAB #2
Digital I/O Programming using PPI
2.0 Objective
The objective of this lab is to work with PPI (Programmable Peripheral Interface) devices which
are used in microprocessor based systems to create programmable I/O Ports.
In this lab, you will do the following:
• Program the PPI devices for different configurations.
• Software based bitwise testing of ports and PPIs.
• Data exchange between the ports
• Write and use delay subroutines.
2.2 Background
8255 is a 40 pin programmable dual in line package. It is a general purpose I/O device. It has
three accessible 8 bit ports named as A, B and C. The 8255 is used in the circuit of Flight-8086
training kit because it is compatible to interface with microprocessor based systems and it
provides the digital I/O ports which can be programmed through software. 8255 is used with a
microprocessor or microcontroller based system with interface like as shown in Figure 2.1. In
addition to these three ports, a third port (Control) is used to program the chip. It has three I/O
ports named as A, B and C. Each of the ports, A or B, can be programmed as an 8-bit input or
output port. Port C can be divided in half, with the top most or bottom most four bits
programmed as inputs or outputs. Individual bits of a particular port cannot be programmed. In
the FLIGTH-86 training system, the 8255 PPI chips are interfaced to two parallel port sockets P1
and P2. In each socket, each one the four ports (A, B, C, and Control) has an individual address
as shown in Table 2.1.The 8255 PPI chip can be programmed to operate in three modes:
• Mode 0: Basic Input/Output.
• Mode 1: Strobed Input/Output.
• Mode 2: Bi-directional bus (not available on FLIGHT-86)
There is also a bit set/reset mode that allows individual bits of port C to be set or reset for control
purposes. Mode 0 gives the simplest form of I/O possible, where no ‘handshaking’ is required.
Data is simply read from or written to the specified port.
2
Electrical Engineering Department, College of Engineering, Qassim University, Buraidah,
Saudi Arabia, Microprocessor Laboratory (EE354)
3
Electrical Engineering Department, College of Engineering, Qassim University, Buraidah,
Saudi Arabia, Microprocessor Laboratory (EE354)
Any one of the ports A, B, C (upper half), and C (lower half) can be set individually as input or
output ports. This is done by sending a control byte to the Control Port. The 16 possible control
words are shown in Table 2.2. Notice that D7, D6, D5, and D2 are fixed for this mode. For
example, to set the three ports as output ports, you need to send the control word 80h to the
control port using the following set of instructions:
2.3 Procedure
org 0050h:0000h
MOV AL,90H
OUT CONTROL,AL
MOV AL,01H
4
Electrical Engineering Department, College of Engineering, Qassim University, Buraidah,
Saudi Arabia, Microprocessor Laboratory (EE354)