Unit Iii I/O Part A: Interfacing
Unit Iii I/O Part A: Interfacing
PART A
1. With neat block diagram explain the 8255 Programmable Peripheral Interface
and its operating modes. [Marks 16]
The 8255 chip is also called as Programmable Peripheral Interface. The Intel 8255A is a
general purpose programmable I/O device which is designed for use with all Intel and most
other microprocessors. It has 3 I/O ports, Port A , Port B and Port C each of 8 bits. The eight
bits of Port C is divided into two 4 bit ports. Cupper (C U) and C lower(CL).
8255 contains two modes of operation Bit Set/Reset Mode(BSR) and I/O
Mode
BSR Mode is used to set or reset the bits in port C which is used for hand shake signals.
Port A
Port C
8255
Port B
Mode 0 Operation (Simple input/output) It does not use any handshake signals. All
the ports are used for simple data transfer.
Mode 1 Operation (Handshake mode) Port A and B are used for data transfer and
Port C is used for hand shake signals.
Mode 2 (Bidirectional Data Transfer)Port A is used for Bidirectional data transfer.
Port B in either in mode 0 or 1. Port C is used for Handshake signals
MODES OF 8255 BIT SET/RESET(BSR) MODE-
Set/Reset bits in Port C
CS Chip Select. A "low" on this input pin enables the communication between the
8255 and the CPU.
RD Read: This control signal enables the read operation. A "low" on this input pin
enables 8255 to read data from the selected I/O.
WR Write: This control signal enables the write operation. A "low" on this input pin
enables 8255 to write a data into the selected I/O or control register.
A0 and A1: These input signals, in conjunction with the RD and WR inputs, control
the selection of one of the three ports or the control word register. They are normally
connected to the least significant bits of the address bus (A0 and A1).
A1 A0 SELECTION
0 0 PORT A
0 1 PORT B
1 0 PORT C
1 1 CONTROL
RESET : A "high" on this input clears the control register and all ports (A, B, C) are
set to the input mode.
PORTS A, B, AND C
The 8255 contains three 8-bit ports (A, B, and C).
Port A: This has an 8 bit latched/buffered O/P and 8 bit input latch. It can be
programmed in 3 modes – mode 0, mode 1, mode 2
Port B: This has an 8 bit latched / buffered O/P and 8 bit input latch. It can be
programmed in mode 0, mode1.
Port C: This has an 8 bit latched input buffer and 8 bit output latched/buffer. This
port can be divided into two 4 bit ports and can be used as control signals for port A
and port B. it can be programmed in mode 0.
Modes of Operation
These are two basic modes of operation of 8255. Bit Set/Reset Mode(BSR) and I/O Mode
In I/O mode, the 8255 ports work as programmable I/O ports, while in BSR mode only port
C can be used to set or reset its individual port bits. It is used to set or reset the bits in
port C which is used for hand shake signals.
The I/O mode is divided into three modes : Mode 0 (Simple input/output) , Mode 1
(Handshake mode) , Mode 2 (Bidirectional Data Transfer)
Mode 0 Operation (Simple input/output) It does not use any handshake signals. All
the ports are used for simple data transfer. It is used for interfacing an i/p device or
an o/p device. It is used when timing characteristics of I/O devices is well known.
Mode 1 Operation (Handshake mode) Port A and B are used for data transfer and
Port C is used for hand shake signals. 3 lines are used for handshaking. It is used for
interfacing an input device or an output device. Handshake signals of the port inform
the processor that the data is available, data transfer complete etc.
Signals STB :
PC4 STBA
The strobe input loads data into the
IBFA port latch on a 0-to-1 transition.
PC5
IBF :
INTR :
INTEB
STBB Interrupt request is an output
PC2
signal that requests an interrupts.
INTE :
PC1 IBFB
The interrupt enable signal is an
internal flip flop used to enable or
disable the generation of INTR
PC3
INTRB signal.
PC7,PC6 :
PORT B I/P PB7 – PB0
The port C pins 7 and 6 are general
purpose I/O pins that are available for
PC 6,7 I/O
INTEA PORTA O/P PA7 – PA0 Mode 1 Output Control Signals
OBFA OBF :
PC7
Output buffer full is an output
signal
that goes low when data is latched
in
PC6 ACKA either port A or port B. Goes low
on
ACK.
PC ACK :
3 that must output a low when the peripheral receives a data.
INTEB
INTR :
PC2 OBFB
Interrupt request is an output
signal that can be used to
ACKB interrupt the MPU to request the
PC1 next data byte for output.
INTE :
INTRB The interrupt enable signal is an
PC3
internal flip flop used to enable or
disable the generation of INTR
PORT B O/P PB7 – PB0 signal.
Port A is used for Bidirectional data transfer. Port B in either in mode 0 or 1. Port C is used
for Handshake signals .This functional configuration provides a means for communicating
with a peripheral device or structure on a single 8-bit bus for both transmitting and receiving
data (bidirectional bus I/O). “Handshaking” signals are provided to maintain proper bus flow.
INTR : Interrupt request is an output signal that can be used to interrupt the MPU to
request the next data byte for output.
OBF : Output Buffer Full is an output indicating that that output buffer contains data for
the bi-directional bus.
ACK : An input from a peripheral device that must output a low when the peripheral
receives a data.
STB : The strobe input loads data into the port A latch.
PA0-PA7 PORT A
STB
PC4
PC5 IBF
INTR
PC3
OBF
PC7
PC6 ACK
I/O
PC0 – PC2
PORT B
IBF : Input buffer full is an output signal indicating that the input latch contains
information for the external bi-directional bus.
INTE : The interrupt enable signal is an internal flip flop used to enable or disable the
generation of INTR signal.
PC2,PC1,PC0 : These port C pins are general-purpose I/O pins that are available for any
purpose.
2. Explain the 8251 USART with neat block diagram. Also explain its
mode word, command word and status word. (16) [Nov/Dec 2011]
A serial communications interface (SCI) is a device that enables the serial (one bit at
a time) exchange of data between a microprocessor and peripherals such as printers,
external drives, scanners. 8251 is a Universal Synchronous and Asynchronous Receiver
and Transmitter compatible with Intel’s processors. This chip converts the parallel data into
a serial stream of bits suitable for serial transmission. It is also able to receive a serial
stream of bits and convert it into parallel data bytes to be read by a microprocessor.
Basic Modes of data transmission
b) Half Duplex Mode: Data transmission may take place in either direction, but
at a time data may be transmitted only in one direction.
c) Full Duplex Mode: Data transmission may take place in both directions
Transmission Rate:
Bits per second: Number of bits transmitted per second.
Baud rate: It is a measurement of transmission speed in asynchronous communication,
it represents the number of bits/sec that are actually being sent over the serial link.
ARCHITECTURE OF 8251A
Data Bus Buffer: This tri-state, bi-directional, 8-bit buffer is used to interface 8251 to
the system data bus. Along with the data, control word, command words and status
information are also transferred through the Data Bus Buffer.
Read/Write Control Logic: This functional block accepts inputs from the system
control bus and generates control signals for overall device operation. It decodes
control signals on the control bus into signals which controls the internal and external
I/O bus. It contains the control word register and command word register that stores
the various controls formats for the device functional definition.
Transmit Buffer: The transmit buffer accepts parallel data from the CPU, adds the
appropriate framing information, serializes it, and transmits it on the TxD pin on the
falling edge of TxC. It has two registers: A buffer register to hold eight bits and an
output register to convert eight bits into a stream of serial bits. The CPU writes a
byte in the buffer register, which is transferred to the output register when it is empty.
The output register then transmits serial data on the TxD pin.
In the asynchronous mode the transmitter always adds START bit; depending
on how the unit is programmed, it also adds an optional even or odd parity bit, and
either 1,11/2, or 2 STOP bits. In synchronous mode no extra bits (other than parity, if
enable) are generated by the transmitter.
Transmit Control
TxRDY (Transmit Ready) :This output signal indicates CPU that buffer register is empty
and the USART is ready to accept a data character. It can be used as an interrupt to the
system or, for polled operation, the CPU can check TxRDY using the status read
operation. This signal is reset when a data byte is loaded into the buffer register.
TxE (Transmitter Empty):This is an output signal. A high on this line indicates that
the output buffer is empty. In the synchronous mode, if the CPU has failed to load a
new character in time, TxE will go high momentarily as SYN characters are loaded
into the transmitter to fill the gap in transmission.
TxC (Transmitter Clock): This clock controls the rate at which characters are
transmitted by USART. In the synchronous mode TxC is equivalent to the baud rate,
and is supplied by the modem. In asynchronous mode TxC is 1, 16, or 64 times the
baud rate. The clock division is programmable. It can be programmed by writing
proper mode word in the mode set register.
Receive Buffer: The receiver accepts serial data on the RxD line converts this serial
data to parallel format, checks for bits or characters that are unique to the
communication technique and sends an “assembled” character to the CPU.
When 8251A is in the asynchronous mode and it is ready to accept a character, it
looks for a low level on the RxD line. When it receives the low level, it assumes that it is a
START bit and enables an internal counter. At a count equivalent to one-half of a bit time,
the RxD line is sampled again. If the line is still low, a valid START bit is detected and the
8251A proceeds to assemble the character. After successful reception of a START bit the
8251A receives data, parity and STOP bits, and then transfers the data on the
receiver input register. The data is then transferred into the receiver buffer register.
In the synchronous mode the receiver simply receives the specified number of data
bits and transfers them to the receiver input register and then to the receiver buffer register.
Receive Control
It manages all receiver-related activities. Along with data reception, it does
false start bit detection, parity error detection, framing error detection, sync detection
and break detection.
RxRDY (Receiver Ready):This is an output signal. It goes high (active), when the
USART has a character in the buffer register and is ready to transfer it to the CPU. This
line can be used either to indicate the status in the status register or to interrupt the
CPU. This signal is reset when a data byte from receiver buffer is read by the CPU.
RxC (Receiver Clock):This clock controls the rate at which the character is to be
received by USART in the synchronous mode. RxC is equivalent to the baud rate,
and is supplied by the modem. In asynchronous mod RxC is 1, 16, or 64 times the
baud rate. The clock division is programmable. It can be programmed by writing
proper mode word in the mode set register.
Modem Control
The 8251 has a set of control inputs and outputs that can be used to simplify the interface to
almost any modem. It provides control circuitry for the generation of RTS and DTR and the
reception of CTS and DSR. In addition, a general purpose inverted output and a general
purpose input are provided. The output is labelled DTR and the input is labelled DSR.
DTR can be asserted by setting bit 2 of the command instruction; DSR can be sensed as
bit 7 of the status register. When used as a modem control signal DTR indicates that the
terminal is ready to communicate and DSR indicates that it is ready for communication.
The receive control unit decides the receiver frequency as controlled by
theRXC input frequency. The receive control unit generates a receiver ready
(RXRDY) signal that may be used by the CPU for handshaking. This unit also
detects a break in the data string while the 8251 is in asynchronous mode. In
synchronous mode, the 8251 detects SYNC characters using SYNDET/BD pin.
Programming 8251
Prior to starting data transmission or reception the 8251 must be sent a set of control
words. This must be done after an external or internal reset. The control words are
split into two formats.
The mode instruction format fixes up the baud rate, number of characters and stop
bits for transmission.
D1-D0 determines whether the USART is to operate in the synchronous (00) or
asynchronous mode. In the asynchronous mode, this field determines the division
factor for clock to decide the baud rate.
D3-D2 determines number of data bits in one character. With this 2 bit field we can
set character length from 5 bits to 8 bits.
D5-D4 controls the parity generation. The parity bit is added to the data bits only if
parity is enabled.
D7-D6 has two meanings depending on whether operation is to be in synchronous mode
or asynchronous mode. In asynchronous mode it controls the number of STOP bits to be
transmitted. In synchronous mode it decides whether to operate with external
synchronization or internal synchronization.
Status Word
The status word enables us to read the status of the device during its operation.
SYNDET
DSR BRKDET FE OE PE TxE RxRDY TxRDY
TxRDY Transmitter Ready : This output signal indicates to the CPU that the internal circuit
of the transmitter is ready to accept a new character for transmission from the CPU.
RxRDY Receiver Ready Output : This output indicates that the 8251A contains a
character to be read by the CPU.
TXE Transmitter Empty : The TXE signal can be used to indicate the end of a
transmission mode.
PE - Parity Error : At the time of transmission of data an even parity or odd parity is
inserted in the data stream. At the receiver end, if parity of the character does not
match with the predefined parity, parity error occurs.
DSR - Data Set Ready : This is normally used to check if data set is ready when
communicating with a modem.
D0 – D7 : This is an 8-bit data bus used to read or write status, command word or
data from or to the 8251A.
C / D : (Control Word/Data): This input pin, together with RD and WR inputs, informs the
8251A that the word on the data bus is either a data or control word/status information. If
this pin is 1, control / status is on the bus, otherwise data is on the bus.
RD : This active-low input to 8251A is used to inform it that the CPU is reading either
data or status information from its internal registers.
WR :This is the "active low" input terminal which receives a signal for writing transmit
data and control words from the CPU into the 8251.
CLK : This input is used to generate internal device timings and is normally
connected to clock generator output. This input frequency should be at least 30
times greater than the receiver or transmitter data bit transfer rate.
RESET : A high on this input forces the 8251A into an idle state. The device will remain
idle till this input signal again goes low and a new set of control word is written into it.
TXC (Transmitter Clock Input) : This transmitter clock input controls the rate at which
the character is to be transmitted.
TXD (Transmitted Data Output) : This output pin carries serial stream of the transmitted
data bits along with other information like start bit, stop bits and parity bit, etc.
RXC (Receiver Clock Input) : This receiver clock input pin controls the rate at which
the character is to be received.
RXD (Receive Data Input) : This input pin of 8251A receives a composite stream of
the data to be received by 8251 A.
RxRDY (Receiver Ready Output) : This output indicates that the 8251A contains a
character to be read by the CPU.
TxRDY - Transmitter Ready : This output signal indicates to the CPU that the internal circuit
of the transmitter is ready to accept a new character for transmission from the CPU.
DSR - Data Set Ready : This is normally used to check if data set is ready when
communicating with a modem.
DTR - Data Terminal Ready : This is used to indicate that the device is ready to
accept data when the 8251 is communicating with a modem.
RTS - Request to Send Data : This signal is used to communicate with a modem.
TXE- Transmitter Empty : The TXE signal can be used to indicate the end of a
transmission mode.
A DAC inputs a binary number and outputs an analog voltage or current signal. The
digital to analog converters converts binary numbers into their analog equivalent
voltages or currents. Several techniques are employed for digital to analog conversion.
Binary Analog
input DAC Output
Basic Concepts
For a 3 bit D/A Converter it has 3 digital input D2, D1 and Do and one output analog signal.
3
The three input lines can assume eight (2 = 8) input combinations from 000 to 111. D2 is
MSB and D0 is LSB. If the input ranges from 0 to 1V it can be divided into eight
equal parts(1/8 V) each successive input is 1/8 V higher than the previous
combinations as shown in the graph below.
The 3 bit D/A converter has eight possible combinations. If a converter has n input
n
lines it can have 2 input combinations.
Characteristics:
Resolution: It is a change in analog output for one LSB change in digital input.
n
It is given by(1/2 )*Vref. If n=8 (i.e.8-bit DAC)1/256*5V=39.06mV
Settling Time: It is the time required for the DAC to settle for a full scale code change.
If the full scale analog voltage is 1 V, the smallest unit or the LSB 001 is equivalent
n
to 1/2 of 1V. This is defined as resolution.
The DAC find applications in areas like digitally controlled gains, motor speed
control, programmable gain amplifiers, digital voltmeters, panel meters, etc. D/A
converter have many applications besides those where they are used with a
microcomputer. In a compact disk audio player for example a 14or16bit D/A
converter is used to convert the binary data read off the disk by a laser to an analog
audio signal. Most speech synthesizer integrated circuits contain a D/A converter to
convert stored binary data words into analog audio signals.
IT
R1 = 2K IT
D2
I1
R = 4K Io
2
D1
I2
R3 = 8K
D0
I3
Io = IT =I1 + I2 + I3
= Vin /R1 +Vin /R2 + Vin /R3
= Vin /1 K(½ + ¼ + 1/8)
= 0.875 mA.
The voltage output
Vo = - R f I T
= - (1 K ) (0.875)
= - 0.875 V
= |7/8 V|
It shows that for the input 111, the output is equal to either 7/8 mA or 7/7 V representing the
D/A conversion process. The diagram is redrawn as shown below, where the input voltage
Vin is replaced by Vref, which can be turned On or OFF by the switches.
Rf
2K 4k8k
I o Vref A 1
A A A A A A
2 3 4 5 6 7
A 8
R 2 4 8 16 32 64 128 256
where A1 to A8 can be 0 or 1
The R-2R ladder DAC, which is a binary weighted DAC that uses a repeating cascaded
structure of resistor values R and 2R. This improves the precision due to the relative ease of
producing equal valued matched resistors (or current sources). However, wide converters
perform slowly due to increasingly large RC-constants for each added R-2R link.
DAC 0800 8-bit Digital to Analog converter
Pin Diagram of DAC 0800:
DAC0800
The digital inputs are converted to current Iout, and by connecting a resistor to the Iout pin,
the output is converted to voltage. The total current I out is a function of the binary
numbers at the B0-B7
inputs of the DAC0808 and the reference current I ref , and it is given by:
D D D
I
D 7D 6 D 5 4
3 D2 D1 0
ref 2 4 8 16 32 64 128 256
Usually reference current is 2mA. Ideally we connect the output pin to a resistor, convert this
current to voltage, and monitor the output on the scope. But this can cause inaccuracy;
hence an operational amplifier is used to convert the output current to voltage.
92
When chip select of DAC is enabled then DAC will convert digital input value given through
portliness PA0-PA7 to analog value. The analog output from DAC is a current quantity. This
current is converted to voltage using OPAMP based current-to-voltage converter. The
Output of DAC-0800 is fed to the operational amplifier to get the final output.
4. Draw and explain the block diagram of A to D converter. [Nov /Dec 2013]
Vin=2.25v, Vref=5v Number of data lines are 5. Convert the given analog quantity into its
equivalent output digital quantity.(8) [May/Jun 2014]
Explain how D/A and A/D interfacing done with 8086 with an application.(10)
[Apr/May 2015]
Vin=2.78v, Vref=5v Number of data lines are 6. Convert the given analog quantity
into its equivalent output digital quantity.(8) [Apr/May 2015]
Analog
Input ADC Binary
Output
An ADC inputs an analog electrical signal such as voltage or current and outputs a
binary number. The function of an A/D converter is to produce a digital word which
represents the magnitude of some analog voltage or current. The specifications for
an A/D converter are very similar to those for D/A converter. The resolution of an A/D
converter refers to the number of bits in the output binary word. An 8-bit converter for
example has a resolution of 1 part in 256. Accuracy and linearity specifications have
the same meaning for an A/D converter as they do for a D/A converter. Another
important specification for an ADC is its conversion time. This is defined as total
time required to convert analog signal into its digital output and is determined by the
conversion technique used and by the propagation delay in various circuits.
Many different types of analog-to-digital converters are available. Differing ADC types offer
varying resolution, accuracy and speed specifications. The most popular techniques used for
Analog-to-Digital conversion are
Successive Approximation Method
0 1 1 1
Te O Te O Te O Te O
st FF st N st N st N
D3 D2 D1 D0
The analog to digital converter chips 0808 and 0809 are 8-bit CMOS,
successive approximation converters. Successive approximation technique isone of
the fast techniques for analog to digital conversion.
A successive approximation ADC employs a digital-to-analog converter (DAC) and a
single comparator. A special shift register called a Successive Approximation Register
(SAR) is used to control the DAC. It provisionally sets each bit of the DAC, beginning with
the most significant bit. The search compares the output of the DAC to the voltage being
measured. If setting a bit to one causes the DAC output to rise above the input voltage, that
bit is set to zero. Otherwise, that bit is left unaltered. This process is continued for all the bits
of the SAR. A Start Conversion (SOC) signal is provided, which when pulsed, initiates the
conversion cycle. An N-bit ADC requires N clock cycles for the conversion of an analog
input. When the conversion is complete, the binary result is placed on the parallel outputs of
the SAR, and the SAR sends out an End-Of Conversion (EOC) signal. For continuous
conversion, the EOC signal may be connected to the SOC signal.
Comparator
Start
Vin
Control
Data
CLK Ready
Output
Register
Analog
Reference
D3 D2 D1 D0
The time taken by the converter to calculate the equivalent digital data output
from the instant of the start of conversion is called conversion delay. It may be
noted that analog input voltage must be constant at the input of the ADC right from
the start of conversion till the end of conversion to get correct results.
Address lines
selected C B A
I/P 0 0 0 0
I/P 1 0 0 1
I/P 2 0 1 0
I/P 3 0 1 1
I/P 4 1 0 0
I/P 5 1 0 1
I/P 6 1 1 0
I/P 7 1 1 1
A dual-slope ADC (DS-ADC) integrates an unknown input voltage (VIN) for a fixed amount
of time (TINT), then "de-integrates" (TDE- INT) using a known reference voltage
(VREF) for a variable amount of time.
At t<0, S1 is set to ground, S2 is closed, and counter=0.
At t=0 a conversion begins and S2is open, and S1is set so the input to the integrator is
Vin.
S1is held for TINT which is a constant predetermined time interval.
When S1is set the counter begins to count clock pulses, the counter resets to zero after
TINT
Vout of integrator at t = TINT is VIN TINT/RC is linearly proportional to VIN
At t = TINT S1is set so Vref is the input to the integrator which has the voltage V IN
TINT /RC stored in it.
The integrator voltage then drops linearly with a slope -V ref/RC.
A comparator is used to determine when the output voltage of the integrator
crosses zero When it is zero the digitized output value is the state of the counter.
5. Explain the different modes of operation of a timer.(8) [Apr/May 2015] [May/Jun 2014]
The data bus buffer is bidirectional, 8-bit buffer and is used to interface the 8253 to the
system data bus. Data is transmitted or received by the buffer. The data bus buffer has three
basic functions, (i) Programming the modes of 8253. (ii) Loading the count value in times
(iii) Reading the count value from timers. The data bus buffer is connected to µ Ρ
which are also bidirectional. The data transfer is through these pins.
Read/ Write Control Logic:
It accepts inputs for the system control bus and in turn generate the control signals
for overall device operation.
CS : The chip select input is used to enable the communication between 8253 and
the microprocessor by means of data bus. A low on CS enables the data bus buffers,
while a high disables the buffer
RD &WR : The read (RD ) and write (WR) pins control the direction of data transfer on
the 8-bit bus. When the RD input pin is low. The CPU is inputting data from 8253 in the
form of counter value. When WR pins is low, then CPU is sending data to 8253 in the
form of mode information or loading counters. The RD &WR should not both be low
simultaneously. When RD & WR pins are HIGH, the data bus buffer is disabled.
A0 & A1: These two input lines are used for counter selection along with the CS pin.
A0 A1 Selected
0 0 Counter 0
0 1 Counter 1
1 0 Counter 2
1 1 Control Register
Counters: Each counter has three pins associated with it. They are CLK (CLK)
the gate (GATE) and the output (OUT).
CLK: Counters operate at the negative edge (1 to 0) of this clock input. If the signal
on this pin is generated by a fixed frequency oscillator then the user has
implemented a standard timer. If the input signal is a string of randomly occurring
pulses, then it is an implementation of a counter.
GATE: The gate input pin is used to initiate or enable counting. The exact effect of
the gate signal depends on which of the six modes of operation is chosen.
OUTPUT: The output pin provides an output from the timer. It actual use
depends on the mode of operation of the timer. The counter can be read “in the
fly” without inhibiting gate pulse or clock input.
M2 M1 M0
0 0 0 Mode 0
0 0 1 Mode 1
x 1 0 Mode 2
x 1 1 Mode 3
1 0 0 Mode 4
1 0 1 Mode 5
It is similar to Mode 2 but the output high and low period is symmetrical. The output goes
high after the count is loaded and it remains high for period which equals the countdown
period of the counter register. The output subsequently goes low for an equal period and
hence generates a symmetrical square wave unlike Mode 2. The GATE has no role here.
In this mode after the count is loaded by the processor the countdown starts. The
output goes low for one clock period after the countdown is complete. The
countdown can be suspended by making the GATE low This is also called a
software triggered strobe as the countdown is initiated by a program.
Mode 5 Hardware Triggered Strobe
The count is loaded by the processor but the countdown is initiated by the GATE
pulse. The transition from low to high of the GATE pulse enables count down. The
output goes low for one clock period after the countdown is complete
Watchdog timer
A Watchdog Timer is a circuit that automatically invokes a reset unless the system
being watched sends regular hold-off signals to the Watchdog.
5. Draw the block diagram of 8279 keyboard/ Display controller and explain hoe
to interface the Hex Key pad and 7- segment LEDs using 8279. (16 Marks)
[April/May 2010, April/May2017]
Intel’s 8279 is a general purpose keyboard display controller that simultaneously drives the
display of a system and interfaces a keyboard with the CPU, leaving it free for its routine task
Modes of Operation
Two-Key Rollover. This means that if two keys are pressed at nearly the same time,
each key will be detected, debounced and converted to ASCII. The ASCII code for
the first key and a strobe signal for it will be sent out then the ASCII code for the
second key and a strobe signal for it will be sent out and compare this with two-key
lockout.
2-Key Lockout Mechanism, one key must be released before the other key is
detected.
N-Key Rollover Mode, if two keys are pressed almost simultaneously,
both key presses are detected and are placed in a queue
ARCHITECTURE OF 8279
Scan Counter :
The scan counter has two modes to scan the key matrix and refresh the display. In the encoded
mode, the counter provides binary count that is to be externally decoded to provide the scan
lines for keyboard and display (Four externally decoded scan lines may drive upto 16 displays).
In the decode scan mode, the counter internally decodes the least significant 2
bits and provides a decoded 1 out of 4 scan on SL 0-SL 3( Four internally decoded scan lines
may drive upto 4 displays). The keyboard and display both are in the same mode at a time.
3. Strobed Input :
In this mode, if the control line goes low, the data on return lines, is stored in the
FIFO byte by byte.
Display Scan : Options for data entry on the displays. The display data is entered
for display either from right side or from the left side.
DISPLAY MODES
There are various options of data display The first one is known as left entry mode or
type writer mode. Since in a type writer the first character typed appears at the left-most
position, while the subsequent characters appears successively to the right of the first
one. The other display format is known as right entry mode, or calculator mode, since
the calculator the first character entered appears at the right-most position and this
character is shifted one position left when the next character is entered.
All the command words or status words are written or read with A0 = 1 and CS = 0 to
or from 8279. This section describes the various command available in 8279.
a) Keyboard Display Mode Set – The format of the command word to select differe
nt modes of operation of 8279 is given below with its bit definitions.
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 D D K K K
D
K K K Keyboard Modes
0 0 0 Encoded Scan 2 Key
Lockout
0 1 0 Decoded Scan 2 Key
Lockout
Encoded Scan N Key Roll
D Display Modes 0 1 0 Over
0 0 Eight 8 bit Character Left Entry Decoded Scan N Key Roll
0 1 1 Over
0 1 Sixteen 8 bit Character Left
1 0 0 Encoded Scan Sensor Matrix
Entry
1 1 0 Decoded Scan Sensor Matrix
1 0 Eight 8 bit Character Right Entry
Sixteen 8 bit Character Right 1 1 0 Strobed input Encoded Scan
1 1
Entry 1 1 1 Strobed input Decoded Scan
b) Read FIFO / Sensor RAM :
The format of this command is given below. This word is written to set up 8279 for reading
FIFO/ sensor RAM. In scanned keyboard mode, AI and AAA bits are of no use. The 8279
will automatically drive data bus for each subsequent read, in the same sequence, in which
the data was entered. In sensor matrix mode, the bits AAA select one of the 8 rows of RAM.
If AI flag is set, each successive read will be from the subsequent RAM location.
D7 D6 D5 D4 D3 D2 D1 D0
0 1 0 AI X A A A
AI – Auto increment
AAA – Address pointer to 8 bit FIFO RAM
D7 D6 D5 D4 D3 D2 D1 D0
0 1 1 AI A A A A
SIGNALS OF 8279
DB0-DB7 : These are bidirectional data bus lines. The data and command words to
and from the CPU are transferred on these lines.
CLK : This is a clock input used to generate internal timing required by 8279.
RESET : This pin is used to reset 8279. A high on this line reset 8279. After resetting
8279, its in sixteen 8-bit display, left entry encoded scan, 2-key lock out mode. The
clock prescaler is set to 31.
CS : Chip Select – A low on this line enables 8279 for normal read or write operations.
RD, WR(Input/Output ) READ/WRITE – These input pins enabl e the data buffers to
receive or send data over the data bus.
IRQ : This interrupt output lines goes high when there is a data in the FIFO sensor RAM.
The interrupt lines goes low with each FIFO RAM read operation but if the FIFO RAM
further contains any key-code entry to be read by the CPU, this pin again goes high
to generate an interrupt to the CPU.
Vss, Vcc : These are the ground and power supply lines for the circuit.
SL0-SL3-Scan Lines : These lines are used to scan the key board matrix and display digits.
These lines can be programmed as encoded or decoded, using the mode control register.
RL0 - RL7 - Return Lines : These are the input lines which are connected to one
terminal of keys, while the other terminal of the keys are connected to the decoded
scan lines. These are normally high, but pulled low when a key is pressed.
SHIFT : The status of the shift input lines is stored along with each key code in FIFO,
in scanned keyboard mode. It is pulled up internally to keep it high, till it is pulled low
with a key closure.
BD – Blank Display : This output pin is used to blank the display during digit
switching or by a blanking closure.
OUT A0 – OUT A3 and OUT B0 – OUT B3 – These are the output ports for two 16*4 or
16*8 internal display refresh registers. The data from these lines is synchronized with the
scan lines to scan the display and keyboard. The two 4-bit ports may also as one 8-bit port.
ARCHITECTURE OF 8259
Priority Resolver
This unit determines the priorities of the interrupt requests appearing simultaneously.
The highest priority is selected and stored into the corresponding bit of ISR during
INTA pulse. The IR0 has the highest priority while the IR7 has the lowest one
Control Logic
This block manages the interrupt and interrupt acknowledge signals to be sent to the CPU
for serving one of the eight interrupt requests. This also accepts interrupt acknowledge
(INTA) signal from CPU that causes the 8259A to release vector address on to the data bus.
Cascade Buffer/Comparator
This block stores and compares the ID's of all the 8259As used in the system. The
three I/O pins CAS0-2 are outputs when the 8259A is used as a master. The same
pins acts as input when 8259 is in slave mode.
1. One or more IR lines are raised high that set corresponding IRR bits.
2. 8259A resolves priority and sends an INT signal to CPU.
3. The CPU acknowledge with INTA pulse.
4. Upon receiving an INTA signal from the CPU, the highest priority ISR bit is set and the
corresponding IRR bit is reset. The 8259A does not drive data during this period.
5. The 8086 will initiate a second INTA pulse. During this period 8259A
releases an 8-bit pointer on to a data bus from where it is read by the CPU.
6. This completes the interrupt cycle. The ISR bit is reset at the end of the
second INTA pulse if automatic end of interrupt (AEOI) mode is programmed.
Otherwise ISR bit remains set until an appropriate EOI command is issued at
the end of interrupt subroutine.
CS: This is an active low chip select signal for enabling RD and WR operations of 8259A.
WR: This pin is an active low write enable input to 8259A. This enables it to
accept command words from CPU.
RD: This is an active low read enable input to 8259A. A low on this line enables
8259A to release status onto the data bus of CPU.
D7-D0: These pins form a bidirectional data bus that carries 8-bit data either to control
word or from status word registers. This also carries interrupt vector information.
PS*/EN*: This pin is a dual purpose pin. When the chip is used in buffered mode, it
can be used as buffer enable to control buffer transceivers. If this is not used in
buffered mode then the pin is used as input.
INT This pin goes high whenever a valid interrupt request is asserted. This is used to
interrupt the CPU and is connected to the interrupt input of CPU.
8259A must be initialized by writing two to four command words into the respective
command word registers. These are called as initialization command words (ICWs).
A0 D7 D6 D5 D4 D3 D2 D1 D0
0 A7 A6 A5 1 LTIM ADI SNGL IC4
LTIM 1: Level triggered A7 – A5 : Interrupt Vector
Address
0 : Edge Triggered IC4 1: ICW4 Needed
ADI: Call address interval 0: Not Needed
1: Interval of 4 bytes SNGL 1: Single
0: Interval of 8 bytes 0 : Cascaded
The SNGL bit in ICW1 indicates whether the 8259A in the cascade mode or not. ADI refers
the interval of call address. LTIM refers whether it is edge triggered or level triggered.
In 8086 based system A15-A11 of the interrupt vector address are inserted in place of
T7 – T 3 respectively and the remaining three bits A 8, A9, A10 are selected
depending upon the interrupt level, i.e. from 000 to 111 for IR0 to IR7.
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 S7 S6 S5 S4 S3 S2 S1 S0
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 0 SFNM BUF M/S AEOI µPM
SFNM: If BUF = 1, the buffered mode is selected. In the buffered mode, SP/EN acts
as enable output and the master/slave is determined using the M/S bit of ICW 4.
M/S: If M/S = 1, 8259A is a master. If M/S =0, 8259A is slave. If BUF = 0, M/S is to
be neglected.
AEOI: If AEOI = 1, the automatic end of interrupt mode is selected.
µPM : If the µPM bit is 0, the Mcs-85 system operation is selected and if µPM=1,
8086/88 operation is selected.
A0D7 D6 D5 D4 D3 D2 D1 D0
1 M7 M6 M5 M4 M3 M2 M1 M0
R SL EOI
End of 0 0 1 Non Specific EOI Command
Interrupt 0 1 1 Specific EOI Command
1 0 1 Rotate on Non Specific EOI Command
Automatic
1 0 0 Rotate in Automatic EOI mode(Set)
Rotation
0 0 0 Rotate in Automatic EOI
mode(Clear)
1 1 1 Rotate on Specific EOI Command
Specific
1 1 0 Set priority Command
Rotation
0 1 0 No operation
A0 D7 D6 D5 D4 D3 D2 D1 D0
0 0 ESMM SMM 0 1 P RR RIS
In operation command word 3 (OCW 3), if the ESMM bit, i.e. enable special mask
mode bit is set to 1, the SMM bit is enabled to select or mask the special mask
mode. When ESMM bit is 0 the SMM bit is neglected. If the SMM bit .i.e. special
mask mode bit is 1, the 8259A will enter special mask mode provided ESMM=1. If
ESMM=1 and SMM=0, the 8259A will return to the normal mask mode.
Fully Nested Mode : This is the default mode of operation of 8259A. IR0 has the highest
priority and IR7 has the lowest one. When interrupt request are noticed, the highest
priority request among them is determined and the vector is placed on the data bus. The
corresponding bit of ISR is set and remains set till the microprocessor issues an EOI
command just before returning from the service routine or the AEOI bit is set. If the
ISR ( in service ) bit is set, all the same or lower priority interrupts are inhibited but
higher levels will generate an interrupt, that will be acknowledge only if the
microprocessor interrupt enable flag IF is set. The priorities can afterwards be
changed by programming the rotating priority modes.
End of Interrupt (EOI) : The ISR bit can be reset either with AEOI bit of ICW1 or by
EOI command, issued before returning from the interrupt service routine. There are
two types of EOI commands specific and non-specific. When 8259A is operated in
the modes that preserve fully nested structure, it can determine which ISR bit is to be
reset on EOI. When non-specific EOI command is issued to 8259A it will be
automatically reset the highest ISR bit out of those already set.
Automatic Rotation : This is used in the applications where all the interrupting devices
are of equal priority. In this mode, an interrupt request IR level receives priority after it is
served while the next device to be served gets the highest priority in sequence. Once all
the devices are served like this, the first device again receives highest priority.
Automatic EOI Mode : Till AEOI=1 in ICW 4, the 8259A operates in AEOI mode. In
this mode, the 8259A performs a non-specific EOI operation at the trailing edge of
the last INTA pulse automatically. This mode should be used only when a nested
multilevel interrupt structure is not required with a single 8259A.
Specific Rotation : In this mode a bottom priority level can be selected, using L 2, L1 and L0
in OCW 2 and R=1, SL=1, EOI=0. The selected bottom priority fixes other priorities. If IR 5 is
selected as a bottom priority, then IR 5 will have least priority and IR4 will have a next higher
priority. Thus IR 6 will have the highest priority. These priorities can be changed during an
EOI command by programming the rotate on specific EOI command in OCW2.
Specific Mask Mode: In specific mask mode, when a mask bit is set in OCW1, it inhibits
further interrupts at that level and enables interrupt from other levels, which are not masked.
Edge and Level Triggered Mode : This mode decides whether the interrupt should
be edge triggered or level triggered. If bit LTIM of ICW1 =0 they are edge triggered,
otherwise the interrupts are level triggered.
The status of the internal registers of 8259A can be read using this mode. The OCW
3 is used to read IRR and ISR while OCW1 is used to read IMR. Reading is possible
only in no polled mode.
Poll Command : In polled mode of operation, the INT output of 8259A is neglected,
though it functions normally, by not connecting INT output or by masking INT input of the
microprocessor. The poll mode is entered by setting P=1 in OCW3. The 8259A is polled by
using software execution by microprocessor instead of the requests on INT input. The
8259A treats the next RD pulse to the 8259A as an interrupt acknowledge. An appropriate
ISR bit is set, if there is a request. The priority level is read and a data word is placed on to
data bus, after RD is activated. A poll command may give more than 64 priority levels.
Special Fully Nested Mode : This mode is used in more complicated system, where
cascading is used and the priority has to be programmed in the master using ICW 4. this is
somewhat similar to the normal nested mode. • In th is mode, when an interrupt request
from a certain slave is in service, this slave can further send request to the master, if the
requesting device connected to the slave has higher priority than the one being currently
served. In this mode, the master interrupt the CPU only when the interrupting device has a
higher or the same priority than the one current being served. In normal mode, other
requests than the one being served are masked out. When entering the interrupt service
routine the software has to check whether this is the only request from the slave. This is
done by sending a non-specific EOI can be sent to the master, otherwise no EOI should be
sent. This mode is important, since in the absence of this mode, the slave would interrupt
the master only once and hence the priorities of the slave inputs would have been disturbed.
Buffered Mode: When the 83259A is used in the systems where bus driving buffers
are used on data buses. The problem of enabling the buffers exists. The 8259A
sends buffer enable signal on SP/ EN pin, whenever data is placed on the bus.
Cascade Mode : The 8259A can be connected in a system containing one master
and eight slaves (maximum) to handle upto 64 priority levels. The master controls
the slaves using CAS 0-CAS 2 which act as chip select inputs (encoded) for slaves.
In this mode, the slave INT outputs are connected with master IR inputs. When a
slave request line is activated and acknowledged, the master will enable the slave to
release the vector address during second pulse of INTA sequence.
The Direct Memory Access or DMA mode of data transfer is the fastest among all the modes
of data transfer. In this mode, the device may transfer data directly to/from memory without
any interference from the CPU. The device requests the CPU (through a DMA controller) to
hold its data, address and control bus, so that the device may transfer data directly to/from
memory. The DMA data transfer is initiated only after receiving HLDA signal from the CPU.
Intel’s 8257 is a four channel DMA controller designed to be interfaced with their family of
microprocessors. The 8257, on behalf of the devices, requests the CPU for bus access
using local bus request input i.e. HOLD in minimum mode. In maximum mode of the
microprocessor RQ/GT pin is used as bus request input. On receiving the HLDA signal (in
minimum mode) or RQ/GT signal (in maximum mode) from the CPU, the requesting devices
gets the access of the bus, and it completes the required number of DMA cycles for the data
transfer and then hands over the control of the bus back to the CPU.
INTERNAL ARCHITECTURE OF 8257
The chip support four DMA channels, i.e. four peripheral devices can independently
request for DMA data transfer through these channels at a time. The DMA controller
has 8-bit internal data buffer, a read/write unit, a control unit, a priority resolving unit
along with a set of registers. The chip support four DMA channels, i.e. four peripheral
devices can independently request for DMA data transfer through these channels at
a time. The DMA controller has 8-bit internal data buffer, a read/write unit, a control
unit, a priority resolving unit along with a set of registers.
If B4 is set, rotating priority is enabled, otherwise, the normal, i.e. fixed priority is enabled If
the TC STOP bit is set, the selected channel is disabled after the terminal count condition is
reached, and it further prevents any DMA cycle on the channel. To enable the channel
again, this bit must be reprogrammed. If the TC STOP bit is programmed to be zero, the
channel is not disabled, even after the count reaches zero and further request are allowed
on the same channel. The auto load bit, if set, enables channel 2 for the repeat block
chaining operations, without immediate software intervention between the two successive
blocks. The channel 2 registers are used as usual, while the channel 3 registers are used to
store the block reinitialisation parameters, i.e. the DMA starting address and terminal count.
After the first block is transferred using DMA, the channel 2 registers are reloaded with the
corresponding channel 3 registers for the next block transfer, if the update flag is set. The
extended write bit, if set to ‘1’, extends the duration of MEMW and IOW signals by activating
them earlier, this is useful in interfacing the peripherals with
D7 D6 D5 D4 D3 D2 D1 D0
The 8-bit. Tristate, bidirectional buffer interfaces the internal bus of 8257 with the external system
bus under the control of various control signals. In the slave mode, the read/write logic accepts
the I/O Read or I/O Write signals, decodes the Ao-A3 lines and either writes the contents of the
data bus to the addressed internal register or reads the contents of the selected register
depending upon whether IOW or IOR signal is activated. In master mode, the read/write logic
generates the IOR and IOW signals to control the data flow to or from the selected peripheral.
The control logic controls the sequences of operations and generates the required control signals
like AEN, ADSTB, MEMR, MEMW, TC and MARK along with the address lines A4-A7, in master
mode. The priority resolver resolves the priority of the four DMA channels depending upon
whether normal priority or rotating priority is programmed.
MODES OF OPERATION
Single mode
In single mode only one byte is transferred per request. For every transfer, the
counting register is decremented and address is incremented or decremented
depending on programming.
DRQo-DRQ3 : These are the four individual channel DMA request inputs, used by the
peripheral devices for requesting the DMA services. The DRQ o has the highest
priority while DRQ3 has the lowest one, if the fixed priority mode is selected.
DACKo-DACK3 : These are the active-low DMA acknowledge output lines which inform
the requesting peripheral that the request has been honoured and the bus is
relinquished by the CPU. These lines may act as strobe lines for the requesting devices.
Do-D7: These are bidirectional, data lines used to interface the system bus with the
internal data bus of 8257. These lines carry command words to 8257 and status
word from 8257, in slave mode, i.e. under the control of CPU. The data over these
lines may be transferred in both the directions. When the 8257 is the bus master
(master mode, i.e. not under CPU control), it uses Do-D7 lines to send higher byte of
the generated address to the latch. This address is further latched using ADSTB
signal. the address is transferred over Do-D7 during the first clock cycle of the DMA
cycle. During the rest of the period, data is available on the data bus.
IOR: This is an active-low bidirectional tristate input line that acts as an input in the
slave mode. In slave mode, this input signal is used by the CPU to read internal
registers of 8257.this line acts output in master mode. In master mode, this signal is
used to read data from a peripheral during a memory write cycle.
IOW : This is an active low bidirection tristate line that acts as input in slave mode to load the
contents of the data bus to the 8-bit mode register or upper/lower byte of a 16-bitDMA
address register or terminal count register. In the master mode, it is a control output that
loads the data to a peripheral during DMA memory read cycle (write to peripheral).
CLK: This is a clock frequency input required to derive basic system timings for the
internal operation of 8257.
RESET : This active-high asynchronous input disables all the DMA channels by
clearing the mode register and tristates all the control lines.
Ao-A3: These are the four least significant address lines. In slave mode, they act as
input which select one of the registers to be read or written. In the master mode,
they are the four least significant memory address output lines generated by 8257.
CS: This is an active-low chip select line that enables the read/write operations
from/to 8257, in slave mode. In the master mode, it is automatically disabled to
prevent the chip from getting selected (by CPU) while performing the DMA operation.
A4-A7 : This is the higher nibble of the lower byte address generated by 8257 during
the master mode of DMA operation.
READY: This is an active-high asynchronous input used to stretch memory read and write
cycles of 8257 by inserting wait states. This is used while interfacing slower peripherals..
HRQ: The hold request output requests the access of the system bus. In the
noncascaded 8257 systems, this is connected with HOLD pin of CPU. In the
cascade mode, this pin of a slave is connected with a DRQ input line of the master
8257, while that of the master is connected with HOLD input of the CPU.
HLDA : The CPU drives this input to the DMA controller high, while granting the bus to the
device. This pin is connected to the HLDA output of the CPU. This input, if high, indicates to
the DMA controller that the bus has been granted to the requesting peripheral by the CPU.
MEMR: This active –low memory read output is used to re ad data from the
addressed memory locations during DMA read cycles.
MEMW : This active-low three state output is used to write data This active-low three
state output is used to write data to the addressed memory location during DMA
write operation. ADST : This output from 8257 strobes the higher byte of the memory
address generated by the DMA controller into the latches.
AEN: This output is used to disable the system data bus and the control the bus driven
by the CPU, this may be used to disable the system address and data bus by using the
enable input of the bus drivers to inhibit the non-DMA devices from responding during
DMA operations. If the 8257 is I/O mapped, this should be used to disable the other I/O
devices, when the DMA controller addresses is on the address bus.
TC: Terminal count output indicates to the currently selected peripherals that the present
DMA cycle is the last for the previously programmed data block. If the TC STOP bit in the
mode set register is set, the selected channel will be disabled at the end of the DMA cycle.
The TC pin is activated when the 14-bit content of the terminal count register of the selected
channel becomes equal to zero. The lower order 14 bits of the terminal count register are to
be programmed with a 14-bit equivalent of (n-1), if n is the desired number of DMA cycles.
MARK : The modulo 128 mark output indicates to the selected peripheral that the
current DMA cycle is the 128th cycle since the previous MARK output. The mark will
be activated after each 128 cycles or integral multiples of it from the beginning if the
data block (the first DMA cycle), if the total number of the required DMA cycles (n) is
completely divisible by 128.
Vcc : This is a +5v supply pin required for operation of the circuit. GND : This is a
return line for the supply (ground pin of the IC).
8. Draw the block diagram of traffic light control system using 8086. [Apr/May
2015]
The Traffic light controller section consists of 12 Nos. of LED’s arranged by 4Lanes
in Traffic light interface card. Each lane has Go(Green), Listen(Yellow) and
Stop(Red) LED is being placed.
PIN ASSIGNMENT WITH 8086
LAN 8086
MODULES
Direction LINES
PA.0 GO
SOUTH PA.1 LISTEN
PA.2 STOP
PA.3 GO
EAST PA.4 LISTEN
PA.5 STOP
PA.6 GO
NORTH PA.7 LISTEN
PB.0 STOP
PB.1 GO
WEST PB.2 LISTEN
PB.3 STOP
13-16 NC
PWR 17,19 Vcc
18,20 Gnd
DELAY: PUSH CX
MOV CX,0005H
REPEAT: MOV DX,0FFFFH
LOOP2: DEC DX
JNZ LOOP2
LOOP REPEAT
POP CX
RET
LOOKUP TABLE
1200 80H