8255 and Interfacing With 8086
8255 and Interfacing With 8086
8255 and Interfacing With 8086
Fig. 14.2 shows the internal 8255 block diagram of 8255 Pin Diagram
Microprocessor. It consists of data bus buffer, control logic and Group A
and Group B controls.
Data Bus Buffer:
The control logic block accepts control bus signals as well as inputs
from the address bus, and issues commands to the individual group
control blocks (Group A control and Group B control). It issues
appropriate enabling signals to access the required data/control words
or status word. The input pins for the control logic section are
described here.
Group A and Group B Controls:
Each of the Group A and Group B control blocks receives control words
from the CPU and issues appropriate commands to the ports associated
with it. The Group A control block controls Port A and PC 7-PC4 while the
Group B control block controls Port B and PC3-PC0.
Port A :
This has an 8-bit latched and buffered output and an 8-bit input latch. It
can be programmed in three modes: mode 0, mode 1 and mode 2.
Port B :
This has an 8-bit data I/O latch/ buffer and an 8-bit data input buffer. It
can be programmed in mode 0 and mode 1.
Port C :
This has one 8-bit unlatched input buffer and an 8-bit output
latch/buffer. Port C can be splitted into two parts and each can be used
as control signals for ports A and B in the handshake mode. It can be
programmed for bit set/reset operation.
Modes of Operation of 8255 Microprocessor:
The individual bits of Port C can be set or reset by sending out a single
OUT instruction to the control register. When Port C is used for
control/status operation, this feature can be used to set or reset
individual bits.
I/O Modes:
In this mode, ports A and B are used as two simple 8-bit I/O ports and
Port C as two 4-bit ports. Each port (or half – port, in case of C) 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. 2. Inputs are buffered, not latched.
3. Ports do not have handshake or interrupt capability.
Mode 1 : Input/Output with handshake:
A high on the RESET pin causes all 24 lines of the three 8-bit ports to be
in the input mode. All flip-flops are cleared and the interrupts are reset.
This condition is maintained even after the RESET goes low. The ports
of the 8255 Pin Diagram can then be programmed for any other mode
by writing a single control word into the control register, when
required.
For Bit Set/Reset Mode:
Fig. 14.6 shows the timing diagram for mode 0 input mode.
Fig. 14.7 shows the timing diagram for mode 0 output mode.
After initialization of 8255 in the output mode 0, CPU can write data
into the output port by initiating write command with proper port
address. CPU sends data on the data bus and upon activation of WR
signal, data on the data bus gets latched on the selected output port.
Mode 0 Configurations :
STB (Strobe Input) : This is an active low input signal for 8255
Programming and Operation and output signal for the input device. The
input device activates this signal to indicate CPU that the data to be
read is already sent on the port lines of 8255 port. Upon activation of
this signal 8255 loads the data from the input port lines into the input
buffer of that port.
IBF (Input Buffer Full) : This is an active high output signal for 8255 and
an input signal for input device. This signal is generated by 8255
Programming and Operation in response to STB signal as an
acknowledgment to input device. It also indicates to the input device
that the input buffer is full and it is not ready to accept next byte from
the input device. Therefore input device sends data on the port lines
only when IBF signal is not active. The IBF signal is deactivated when
CPU reads the data from input buffer of the respective port by
activation of RD signal.
INTR (Interrupt Request) : This is an active high output signal generated
by 8255. A ‘high’ on this output can be used to interrupt the CPU when
an input device is requesting service. The 8255 Programming and
Operation sets the INTR when STB signal is ‘one’, IBF signal is ‘one’ and
INTE is ‘one’, indicating CPU that the data from the input device is
available in the input buffer. This signal is reset by the falling edge of
the RD signal i.e. immediately after reading the data from the input
buffer.
INTE (Interrupt Enable) flip flop is used to enable or disable INTR
(Interrupt request) signal. If INTE flip-flop is set, the interrupt request is
generated depending on the status of STB and IBF signals. If INTE flip
flop is reset, the interrupt request is not generated, allowing masking
facility for the interrupt.
Mode 1 : Port A Input Operation :
Fig. 14.8 (a) (see Fig. on next page) shows Port A as an input port along
with the control word and control signals (for handshaking with a
peripheral). When the control word (as in Fig. 14.8 (a) is loaded into the
control register, Group A is configured in Mode 1 with Port A as an
input port. Port A can accept parallel data from a peripheral (like a
keyboard) and this data can be read by the CPU. The peripheral first
loads data into Port by making the STB A input low. This latches the data
placed by the peripheral on the common data bus into Port A. Port A
acknowledges reception of data by making IBF A (Input Buffer Full) high.
IBFA is set when the STBA input is made low, as shown in Fig. 14.8 (b).
INTRA is an active high output signal which can be used to interrupt the
CPU so that the CPU can suspend its current operation and read the
data written into Port A by the peripheral. INTR A can be enabled or
disabled by the INTEA flip-flop which is controlled by Bit Set-Reset
operation of PC4. INTRA is set (if enabled by setting the INTE A flip-flop)
after the STBA has gone high again, and if IBFA is high.
On receipt of the interrupt, the CPU can be forced to read Port A. The
falling edge of the RD input resets IBFA and it goes low. This can be
used to indicate to the peripheral that the input buffer is empty and
that data can again be loaded into it.
Mode 1 : Port B Input operation:
Fig. 14.9 shows Port B as an input port (when in Mode 1). The timing
diagram and operation of Port B is similar to that of Port A except that
it uses different bits of Port C for control. INTE B is controlled by Bit
Set/Reset of PC2.
If the CPU is busy with other system operations, it can read data from
the input port when it is interrupted. This is often called Interrupt
driven I/O. However, if the CPU is otherwise not busy with other jobs, it
can continuously poll (read) the status word to check for an IBF A. This is
often called Program Controlled I/O. The status word is accessed by
reading Port C (A 1 A 0 must be 10, RD and CS must be low).. The status
word format when Ports A and B are input ports in Mode 1, is shown in
Fig. 14.10.
This is an active low output signal for 8255 Programming and Operation
and input signal for the output device. The 8255 activates this signal to
indicate output device that data is available on the output port. Upon
activation of OBF signal, output device reads data from the output port
and acknowledges it by ACK signal. The OBF signal is activated at the
rising edge of the WR signal and de-activated at the falling edge of the
ACK signal.
2.ACK (Acknowledge Input):
This is an active low input signal for 8255 and output signal for the
output device. The output device generates this signal to indicate 8255
that the data from port A or Port B has been accepted.
3.INTR (Interrupt Request) :
Fig. 14.14 shows the control word that should be loaded into the
control port to configure 8255 in Mode 2,
Mode 2 : Control signals:
This is an active low output which indicates that the CPU has written
data into Port A.
ACKA (Acknowledge):
This is the flip-flop associated with Output Buffer Full. INTE 1 can be
used to enable or disable the interrupt by setting or resetting PC 6 in the
BSR Mode.
Input Control Signals:
This is an active low input signal which enables Port A to latch the data
available at its input.
IBF (Input Buffer Full Flip-Flop):
This is an active high output which indicates that data has been loaded
into the input latch of Port A.
INTE 2:
Fig. 14.15 (see Fig. on next page) shows Port A and associated control
signals when 8255 is in Mode 2. Interrupts are generated for both
output and input operations on the same INTRA (PC3) line.
Status Word In Mode 2:
The mode definition format for I/O mode is shown in Fig. 14.5. The
control words for both, mode definition and Bit Set –Reset are loaded
into the same control register, with bit D 7 used for specifying whether
the word loaded into the control register is a mode definition word or
Bit Set-Reset word. If D7 is high, the word is taken as a mode definition
word, and if it is low, it is taken as a Bit Set-Reset word. The appropriate
bits are set or reset depending on the type of operation desired, and
loaded into the control register.
8255 Interfacing with 8086:
Fig. 14.17 shows the 8255 Interfacing with 8086 Microprocessor and
Interfacing 8255 with 8085 Microprocessor in I/O mapped I/O
technique. Here RD and WR signals are activated when IO/M signal is
high, indicating I/O bus cycle. Reset out signal from 8085 is connected
to the RESET signal of the 8255.
Fig. 14.18 shows the interfacing of 8255 with 8085 in memory mapped
I/C technique. Here RD and WR signals are activated when 10/M signal
is low, indicating memory bus cycle. To get absolute address, all
remaining address lines (A15 – A2) are used to decode the address for
8255. Other signal connections are same as in I/C mapped I/O.
8255 Interfacing with 8086 in I/O Mapped I/O Mode:
The 8086 has four special instructions IN, INS, OUT, and OUTS to
transfer data through the input/output ports in I/O mapped I/O system.
M/IO signal is always low when 8086 is executing these instructions. So
M/IO signal is used to generate separate addresses for, memory and
input/output. Only 256 (28) I/O addresses can be generated when direct
addressing method is used. By using indirect address method this range
can be extended upto 65536 (216) addresses.
Fig. 14.19 shows the 8255 Interfacing with 8086 in I/O mapped I/O
technique. Here, RD and WR signals are activated when M/IO signal is
low, indicating I/O bus cycle. Only lower data bus (D 0 — D7) is used as
8255 is 8-bit device. Reset out signal from clock generator is connected
to the Reset signal of the 8255. In case of interrupt driven I/O INTR
signal (PC3 or PC0) from 8255 is connected to INTR input of 8088.
8255 Interfacing with 8086 in Memory Mapped I/O:
In this type of I/O interfacing, the 8086 uses 20 address lines to identify
an I/O device; an I/O device is connected as if it is a memory register.
The 8086 uses same control signals and instructions to access I/O as
those of memory. Fig. 14.20 shows the 8255 Interfacing with 8086 in
memory mapped I/O technique. Here RD and WR signals are activated
when M/IO signal is high, indicating memory bus cycle. Address lines
A0 – A1 are used by 8255 for internal decoding. To get absolute address,
all remaining address lines (A3 – A19) are used to decode the address for
8255. Other signal connections are same as in I/O napped I/O.
Applications: