What Is An Interface ?
What Is An Interface ?
In computing, an interface is a shared boundary across which two or more separate components of a
computer system to exchange information.
The exchange can be between software, computer hardware, peripheral devices, humans, and
combinations of these.
Some computer hardware devices, such as a touchscreen, can both send and receive data through
the interface, while others such as a mouse or microphone may only provide an interface to send data
to a given system.
A hardware interface is described by the mechanical, electrical and logical signals at the interface
and the protocol for sequencing them (sometimes called signaling).
A standard interface, such as Small Computer System Interface (SCSI), decouples the design
and introduction of computing hardware, such as I/O devices, from the design and introduction of
other components of a computing system, thereby allowing users and manufacturers great
flexibility in the implementation of computing systems.
A software interface may refer to a wide range of different types of interface at different "levels": an
operating system may interface with pieces of hardware.
Applications or programs running on the operating system may need to interact via data streams,
filters, and pipelines; and
in object oriented programs, objects within an application may need to interact via methods.
In computer system, there are special hardware components between the CPU and peripherals to
control or manage the input-output transfers.
These components are called input-output interface units because they provide communication
links between processor bus and peripherals.
There are two types of interfacing in 8085 - Memory Interfacing & I/O Interfacing.
The use of interfaces allows for a programming style called programming to the interface.
The idea behind this approach is to base programming logic on the interfaces of the objects used,
rather than on internal implementation details.
Programming to the interface reduces dependency on implementation specifics and makes more
reusable.
Pushing this idea to the extreme, inversion of control leaves the context to inject the code with the
specific implementations of the interface that will be used to perform the work.
Programmable interface device
Such a device is set up to perform functions by writing an instruction in its internal register, the control
register.
These devices are flexible, versatile and economical and widely used in microprocessor based products.
• Parallel I/O
• Serial I/O
• Interrupt controller
When we are executing any instruction, we need the microprocessor to access the memory for
reading instruction codes and the data stored in the memory.
The interfacing circuit therefore should be designed in such a way that it matches the memory
signal requirements with the signals of the microprocessor.
The purpose of IOP is to provide an independent pathway for the transfer of information
between external device and internal memory.
Asynchronous Data Transfer : This Scheme is used when speed of I/O devices do not match
with microprocessor, and timing characteristics of I/O devices is not predictable.
Programmable peripheral interface
The 8255A is a general purpose programmable I/O device designed to transfer the data
from I/O to interrupt I/O under certain conditions as required.
It consists of three 8-bit bidirectional I/O ports (24I/O lines) which can be configured as per
the requirement.
Port A contains one 8-bit output latch/buffer and one 8-bit input buffer.
Port C can be split into two parts, i.e. PORT C lower (PC0-PC3) and PORT C upper (PC7-
PC4
8255Pin diagram
It stands for Chip Select. A LOW on this input selects the chip and enables the communication
between the 8255A and the CPU.
It is connected to the decoded address, and A0 & A1 are connected to the microprocessor
address lines.
CS A1 A0 Result
0 0 0 PORT A
0 0 1 PORT B
0 1 0 PORT C
Control
0 1 1
Register
No
1 X X
Selection
WR
When this signal goes low, the microprocessor writes into a selected I/O port or control register.
RESET
It clears the control register and sets all ports in the input mode.
RD
When the signal is low, the microprocessor reads the data from the selected I/O port of the 8255.
A0 and A1
These input signals work with RD, WR, and one of the control signal. Following is the table
showing their various signals with their result.
To communicate with peripherals through 8255, three steps are necessary :
A,B and C
Control word format
D0, D1, D3, D4 are assigned for port C lower, port B, port C upper and port A respectively. When
For e.g., if D0 = D4 = 1, then lower port C and port A act as input ports.
If these bits are 0, then the corresponding port acts as an output port.
For e.g., if D1 = D3 = 0, then port B and upper port C act as output ports.
D2 is used for mode selection of Group B (port B and lower port C).
D5 & D6 are used for mode selection of Group A ( port A and upper port C).
D7 = 1, as it is I/O mode
Operating modes of 8255
1. Bit set reset (BSR) mode
Each line of port C (PC7 - PC0) can be set or reset by writing a suitable value in the
BSR mode and I/O mode are independent and selection of BSR mode does not affect
By setting the MSB of control word (D7) to 0, PPI works in BSR mode.
Write a BSR control word subroutine to set bits pc7 and pc3 and reset them after 10ms
To set PC7 control word will be D7 D6 D5 D4 D3 D2 D1 D0
As an example, to set PC5, then in the CW is ,
0 0 0 0 1 1 1 1 = 0F H
To reset PC7 control word will be D7 D6 D5 D4 D3 D2 D1 D0
1.Since it is BSR mode, D7 = '0'.
0 0 0 0 1 1 1 0 = 0E H
To set PC3 control word will be D7 D6 D5 D4 D3 D2 D1 D0 2.Since D4, D5, D6 are not used, assume them to be '0'.
0 0 0 0 0 1 1 1 = 07 H
To reset PC3 control word will be D7 D6 D5 D4 D3 D2 D1 D0 3.PC5 has to be selected, hence, D3 = '1', D2 = '0', D1 = '1'.
0 0 0 0 0 1 1 0 = 06 H
MVI A, 0FH // Load byte in accumulator to set PC7 4.PC5 has to be set, hence, D0 = '1'.
OUT 83H // Set PC7=1
Thus, as per the above values, 0B (Hex) will be loaded
MVI A, 07H // Load byte in accumulator to set PC3
OUT 83H // Set PC3=1 into the Control Word Register (CWR).
CALL DELAY // delay routine for 10ms
MVI A, 06H // Load byte in accumulator to reset PC3
OUT 83H // Set PC7=1
MVI A, 0EH // Load byte in accumulator to reset PC7
OUT 83H // Set PC7=1
RET
2. Input-Output mode (I/O mode)
By setting the MSB of control word (D7) to 1, PPI works in input-output mode.
This is further divided into three modes: Mode 0, Mode 1 and Mode 2
Mode 0 − In this mode, Port A and B is used as two 8-bit ports and Port C as two 4-bit ports.
Each port can be programmed in either input mode or output mode where outputs are
latched and inputs are not latched. Ports do not have interrupt capability.
Mode 1 − In this mode, Port A and B is used as 8-bit I/O ports. They can be configured as
either input or output ports. Each port uses three lines from port C as handshake signals.
Inputs and outputs are latched.
Mode 2 − 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.
For example, if port B and upper port C have to be
initialized as input ports and lower port C and port A as
output ports (all in mode 0):
operation.
ports, hence, D1 = D3 = 1.
ports, hence, D4 = D0 = 0.
In this mode, the ports can be used for simple I/O operations without handshaking signals.
2 halves of port C can be either used as an additional 8-bit port, or as 2 individual 4-bit ports.
Since the two halves of port C are independent, they may be used such that one-half is initialized as
its output constant even if the inputs change after being latched.
The 8255's outputs are latched to hold the last data written to them.
This is required because the data only stays on the bus for one cycle.
Without latching, the outputs would become invalid as soon as the write cycle finishes.
The inputs are not latched because the CPU only has to read their current values, then
store the data in a CPU register or memory if it needs to be referenced at a later time.
If an input changes while the port is being read then the result may be indeterminate.
Mode 0 – input mode
•In this mode, the 8255 gets data from the external peripheral ports and the CPU reads the received data via its
data bus.
•The CPU first selects the 8255 chip by making CS low. Then it selects the desired port using A 0 and A1 lines.
•The CPU then issues an RD signal to read the data from the external peripheral device via the system data bus
•In this mode, the CPU sends data to 8255 via system data bus and then the external peripheral ports receive
•CPU first selects the 8255 chip by making CS low. It then selects the desired port using A 0 and A1 lines.
•CPU then issues a WR signal to write data to the selected port via the system data bus. This data is then
RLC
RLC
RLC
HLT
Design an interfacing ckt to read data from an A/D converter using 8255A in memory – mapped I/O
1 0 0 1 1 0 0 0 = 98 H
D7 D6 D5 D4 D3 D2 D1 D0
Set =01 H
Reset = 00H
0 0 0 0 0 0 0 1/0
SUBROUTINE
LXI H, 8003H // CR
MVI A, 98H // Cw
MOV M,A // CW-> CR
MVI A, 01H // BSR to set PC0
MOV M,A // load ACC with CW
CALL DELAY // delay
MVI A, 00H // reset PC0
Read : MOV M,A
DCX H // Port C
MOV A,M // read port C
RAL // place PC7 in carry
JC READ // wait in loop for EoC
LDA 8000H // Read A/D converter
RET
Mode 1 - Strobed Input/output mode
To use port A or port B for handshake (strobed) input or output operation, initialise that port in mode 1.
Port A and Port B can be initialised to operate in different modes, i.e., for e.g., Port A can operate in
mode 0 and Port B in mode 1.
Some of the pins of port C function as handshake lines.
For port B in this mode (irrespective of whether is acting as an input port or output port), PC0, PC1
and PC2 pins function as handshake lines.
If port A is initialised as mode 1 input port : then, PC3, PC4 and PC5 function as handshake signals.
Pins PC6 and PC7 are available for use as input/output lines.
The mode 1 which supports handshaking has following features:
1.Two ports i.e. port A and B can be used as 8-bit i/o ports.
2.Each port uses three lines of port c as handshake signal and remaining two signals can be used as
i/o ports.
3.Interrupt logic is supported.
4.Input and Output data are latched.
Input configuration Control word and status word format
Mode 1: Input Control Signals
1.STB (Strobed Input) - This signal is active low & generated by the peripheral
The strobe input loads data into the port latch, which holds the information until it
indicate that the input latch has received the data byte. This is rest when the MPU
This signal is generated if STB, IBF and INTE are all at logic 1.
The INTR pin becomes a logic 1 when the STB input returns to a logic 1, and is
cleared when the data are input from the port by the microprocessor.
8255 can be programmed to function using either status I/O or interrupt I/O.
Interrupt I/O
Status check I/O
The MPU continuously checks the
status of the IBF line until it goes high
Mode 1 : Output Control signals
Output configuration
Mode 1 : Output Control signals
1. OBF (output signal) - This output signal goes low when the MPU writes data into the output latch off
8255. This indicates the peripheral that the new data is ready to read. It goes high after 8255 receives
2. ACK (Input Signal) - The peripheral outputs a low when it receives the data from the 8255 ports.
3. INTR (Interrupt request) - It is an output signal and set by the rising edge of the ACK signal. This is
used to interrupt the MPU to request the next data byte for output.
This signal is set when OBF, ACK and INTE are all high and rest by the falling edge of WR.
4. INTE (Interrupt enable) - It is an internal FF to a port and needs to be set to generate the INTR signal.
The two FF’s INTE A & INTE B) are controlled by the bits PC6 and PC2 through BSR mode.
Port A is the input port for the keyboard with interrupt I/O
2. Determine the control word to setup Port A as input and Port B as output in
Mode 1.
4. Determine the masking byte to verify the OBF B line in the status check I/O
(port B)
1 0 1 1 1 0 1 0 0 = B4 H Print subroutine
This means that data can be input or output on the same eight lines (PA0 - PA7).
The remaining pins of port C (PC0 - PC2) can be used as input/output lines if group B is initialized
In this mode, the 8255 may be used to extend the system bus to a slave microprocessor or to
Acknowledgement and handshaking signals are provided to maintain proper data flow and