Professional Documents
Culture Documents
Module IV - Interface Peripherals To 8086
Module IV - Interface Peripherals To 8086
Course Objectives:
1. To study the architecture of the general purpose
microprocessors 8086 and advanced Processors.
2. To understand the assembly language programming of 8086
processor.
3. To impart knowledge about assembly language programming
to interface various peripherals like data converters,
keyboards, display units etc.,
4. To interface different peripheral units with microprocessors
i.e., the hardware of various consumer electronic goods.
5. To design and implement microprocessor based embedded
systems.
Course Outcomes:
Students will be able to
1. Acquire the knowledge of the internal architecture, memory
organization and operating modes of processors.
2. To write efficient codes on 6-bit platform.
3. interface the microprocessor with different peripheral ICs
such as 8255, 8251, 8253, 8279 etc.,
4. Design standalone microprocessor - based systems.
Prepared by
Dr Sreenivasa Rao Ijjada
Dept of ECE,GIT, GITAM University, Visakhapatnam
2019-2020
dr.ijjada2019@gmail.com
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 1
Module IV 10 hours
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 2
Programmable peripheral interface 8255:
8255A is a versatile TTL compatible general purpose programmable I/O port
device designed by Intel to interface the CPU with its outside world such as
ADC, DAC, keyboard etc. It can be programmed according to the given
conditions and applications. It can be used with almost any microprocessor.
Address/data bus must be externally de-multiplexed.
Ports of 8255A: 8255A consists of three 8-bit bidirectional I/O ports (24
I/O lines) such as PORT A, PORT B, and PORT C which can be configured
as per the requirement..
Port A contains one 8-bit output latch/buffer and one 8-bit input
buffer.
Port B is similar to PORT A.
Port C can be split into two parts, i.e. PORT C lower (PC0-PC3) and
PORT C upper (PC7-PC4).
The three ports are further divided into two groups, i.e. Group A which
includes PORT A and upper PORT C. Group B includes PORT B and lower
PORT C. The two groups can be programmed in three different modes as
Mode 0, Mode 1 and Mode 2.
Mode 0(Simple I/O mode) –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.
Example: A CPU wants to transfer data to a printer. In this case since speed
of processor is very fast as compared to relatively slow printer, so before
actual data transfer it will send handshake signals to the printer for
synchronization of the speed of the CPU and the peripherals.
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 3
Mode 2(Bi-directional data bus mode) – In this mode, Port A can be
configured as the bidirectional port and Port B can be 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.
Architecture of 8255:
The architecture of the 8255 is shown in the figure 5.2, it has the following
blocks
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 4
CS’ (Chip Select): A LOW on this input line 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.
0 0 0 PORT A 80 H
0 0 1 PORT B 81 H
0 1 0 PORT C 82 H
0 1 1 Control Register 83 H
1 X X No Seletion X
WR’: A low signal on this input line enables the write operation. With signal,
the microprocessor writes something into a selected I/O port or control
register.
RESET: This is an active high signal. It clears the control register and sets
all ports in the input mode.
RD’: It stands for Read. This control signal enables the Read operation.
When the signal is low, the microprocessor reads the data from the selected
I/O port of the 8255.
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 5
A1 A0 RD’ WR’ CS’ Result
0 0 0 1 0 Input Operation
PORT A → Data Bus
Output Operation
0 0 1 0 0
Data Bus → PORT A
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 6
Fig.4.4: The interfacing diagram of 8255 with the 8086 processor
Operating modes: There are to operating modes in the 8255, they are
Input-Output mode
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 7
Bit set reset (BSR) mode –If MSB of control word (D7) is 0, PPI works in
BSR mode. In this mode only port C bits are used for set or reset.
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 8
MNEMONICS COMMENTS
MVI A, 90 A ← 92
IN 80 A ← Port A;
MOV B, A B ← A;
IN 81 A ← Port B;
ADD B A ← A+B;
OUT 82 Port C ← A
RET Return
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 9
8251 USART (universal synchronous asynchronous receiver
transmitter):
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 10
Read/Write control logic –It is a control block for overall device. It controls
the overall working by selecting the operation to be done. The operation
selection depends upon input signals as:
In this way, this unit selects one of the three registers- data buffer register,
control register, status register.
Transmit buffer –This block is used for parallel to serial converter that
receives a parallel byte for conversion into serial signal and further
transmission onto the common channel.
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 11
Transmit control –This block is used to control the data transmission with
the help of following pins:
TXC’: An active-low input pin which controls the data transmission rate of
transmitted data.
Receive buffer – This block acts as a buffer for the received data.
RXC’: An active-low output signal which controls the data transmission rate
of received data.
8251 Pin description: USART pin diagram is shown in the fig.5.8. The 8251
chip is Universal Synchronous Asynchronous Receiver Transmitter (USART).
It acts as a mediator between the microprocessor and peripheral devices. It
converts serial data to parallel form and vice versa. This chip is 28 pin DIP.
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 12
2. Command (setting of operation)
Mode Instruction: Mode instruction is used for setting the function of the
8251. Mode instruction will be in "wait for write" at either internal reset or
external reset. That is, the writing of a control word after resetting will be
recognized as a "mode instruction." Items set by mode instruction are as
follows:
o Synchronous/asynchronous mode
o Stop bit length (asynchronous mode)
o Character length
o Parity bit
o Baud rate factor (asynchronous mode)
o Internal/external synchronization (synchronous mode)
o Number of synchronous characters (Synchronous mode)
The bit configuration of mode instruction is shown in Fig. 5.9 and 5.10. In
the case of synchronous mode, it is necessary to write one-or two byte sync
characters. If sync characters were written, a function will be set because
the writing of sync characters constitutes part of mode instruction
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 13
Fig.4.10: bit configuration of Mode instruction (synchronous)
Control register: This is 16 bit register and the control word consists of two
independent bytes; first byte is called Mode Instruction (Word) and the
second byte is called the Command Instruction (Word). This register can be
accessed as an output port when C/D’ is Low.
Command control word: Command is used for setting the operation of the
8251. It is possible to write a command whenever necessary after writing a
mode instruction and sync characters. Items to be set by command are as
follows:
o Transmit Enable/Disable
o Receive Enable/Disable
o DTR, RTS Output of data.
o Resetting of error flag.
o Sending to break characters
o Internal resetting
o Hunt mode (synchronous mode)
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 14
Fig.4.11: bit configuration of command control word
Status Word: It is possible to see the internal status of the 8251 by reading
a status word. The bit configuration of status word is shown in Fig. 5.12.
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 15
Digital to Analog converters (DAC 0800)
The DAC0800 is an 8-bit, high speed, current output DAC with a typical
settling time (conversion time) of 100 ns. It produces complementary current
output, which can be converted to voltage by using simple resistor load. The
Reference voltage for conversion is provided using +Vref and –Vref. The
output can be amplified (optional) using an op-amp. DACs are used in
various applications such as Waveform generation, PWM, Motor control
Applications, DSP etc. Here we connect the output to a display device like
CRO. By simple programmings we can generate several types of wave forms
like Ramp, Saw-tooth, Triangular waveform etc.
The DAC 0800 consists of 8 data lines and REF voltage lines. The output
from 0808 DAC is current. When the DAC is given the digital input it
converts the Digital data to corresponding current, to convert current to
voltage with UA 741 as shown in figure 5.13 below:
Pin 5 -12(A1, A2,--A8): Digital information can be fed to the DAC through
these lines.
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 16
Pin 3: Gnd
Pin 14 &15: these are the reference pins, generally pin 15 is grounded and
pin 15 is connected to +5V. The DAC0800 require a positive and a negative
supply voltage in the range of ± 5V to ±18V.
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 17
Analog to Digital converter (ADC 0808/0809)
The process of analog to digital conversion is a slow process, and the
microprocessor has to wait for the digital data till the conversion is over.
After the conversion is over, the ADC sends end of conversion EOC signal to
inform the microprocessor that the conversion is over and the result is ready
at the output buffer of the ADC. These tasks of issuing an SOC pulse to
ADC, reading EOC signal from the ADC and reading the digital output of the
ADC are carried out by the CPU using 8255 I/O ports.
The time taken by the ADC from the active edge of SOC pulse till the active
edge of EOC signal is called as the conversion delay of the ADC. It may
range anywhere from a few microseconds in case of fast ADC to even a few
hundred milliseconds in case of slow ADCs. The available ADC in the
market use different conversion techniques for conversion of analog signal to
digitals. Successive approximation techniques and dual slope integration
techniques are the most popular techniques used in the integrated ADC
chip.
Analog input voltage must be constant at the input of the ADC right from
the start of conversion till the end of the conversion to get correct results.
This may be ensured by a sample and hold circuit which samples the analog
signal and holds it constant for specific time duration. The microprocessor
may issue a hold signal to the sample and hold circuit. If the applied input
changes before the complete conversion process is over, the digital
equivalent of the analog input calculated by the ADC may not be correct
The analog to digital converter chips 0808 and 0809 are 8-bit CMOS,
successive approximation converters. This technique is one of the fast
techniques for analog to digital conversion. The conversion delay is 100μs at
a clock frequency of 640 KHz, which is quite low as compared to other
converters. These converters do not need any external zero or full scale
adjustments as they are already taken care of by internal circuits. These
converters internally have a 3:8 analog multiplexer so that at a time eight
different analog conversion by using address lines –
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 18
Fig.4.15: Block diagram of ADC 0808
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 19
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 20
General algorithm for ADC interfacing contains the following steps:
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 21
Programmable Interval Timers (PTIs) 8253/8254
The Intel 8253 and 8254 are Programmable Interval Timers (PTIs) designed
for microprocessors to perform timing and counting functions using three
16-bit registers. Each counter has 2 input pins, i.e. Clock & Gate, and 1 pin
for “OUT” output. To operate a counter, a 16-bit count is loaded in its
register. On command, it begins to decrement the count until it reaches 0,
then it generates a pulse that can be used to interrupt the CPU.
Features of 8253/54
These three counters can be programmed for either binary or BCD count.
8254 has a powerful command called READ BACK command, which allows
the user to check the count value, the programmed mode, the current mode,
and the current status of the counter.
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 22
In the above figure, there are three counters, a data bus buffer, Read/Write
control logic, and a control register. Each counter has two input signals -
CLOCK & GATE, and one output signal - OUT.
Read/Write Logic: It includes 5 signals, i.e. RD, WR, CS, and the address
lines A0 & A1. In the peripheral I/O mode, the RD and WR signals are
connected to IOR and IOW, respectively. In the memory mapped I/O mode,
these are connected to MEMR and MEMW.
Address lines A0 & A1 of the CPU are connected to lines A0 and A1 of the
8253/54, and CS is tied to a decoded address. The control word register and
counters are selected according to the signals on lines A0 & A1.
A1 A0 Result
0 0 Counter 0
0 1 Counter 1
1 0 Counter 2
X X No Selection
Control Word Register: This register is accessed when lines A0 & A1 are at
logic 1. It is used to write a command word, which specifies the counter to
be used, its mode, and either a read or write operation. Following table
shows the result for various control inputs.
A1 A0 RD WR CS Result
0 0 1 0 0 Write Counter 0
0 1 1 0 0 Write Counter 1
1 0 1 0 0 Write Counter 2
0 0 0 1 0 Read Counter 0
0 1 0 1 0 Read Counter 1
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 23
1 0 0 1 0 Read Counter 2
1 1 0 1 0 No operation
X X 1 1 0 No operation
X X X X 1 No operation
Initially the output is low after the mode is set. The output remains LOW
after the count value is loaded into the counter.
The process of decrementing the counter continues till the terminal count is
reached, i.e., the count become zero and the output goes HIGH and will
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 24
remain high until it reloads a new count. The GATE signal is high for normal
counting. When GATE goes low, counting is terminated and the current
count is latched till the GATE goes high again.
Mode 3(Square Wave Generator): This mode is similar to Mode 2 except the
output remains low for half of the timer period and high for the other half of
the period.
Mode 4(Software Triggered Mode): In this mode, the output will remain
high until the timer has counted to zero, at which point the output will
pulse low and then go high again.
The count is latched when the GATE signal goes LOW. On the terminal
count, the output goes low for one clock cycle then goes HIGH. This low
pulse can be used as a strobe.
Dr.Sreenivasa Rao Ijjada, Dept of ECE, GIT, GITAM University Visakhapatnam Page 25