0% found this document useful (0 votes)
3 views27 pages

8255 and Input output interfacing_6

This document provides an overview of I/O interfaces in microprocessor systems, detailing the functions of input and output ports, serial and parallel transmission methods, and interrupt-driven I/O techniques. It also describes the Intel 8255 programmable peripheral interface, including its modes of operation and pin configuration. The document emphasizes the importance of data transfer between microprocessors and external devices, highlighting various operational modes for effective communication.

Uploaded by

Ranju samanta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views27 pages

8255 and Input output interfacing_6

This document provides an overview of I/O interfaces in microprocessor systems, detailing the functions of input and output ports, serial and parallel transmission methods, and interrupt-driven I/O techniques. It also describes the Intel 8255 programmable peripheral interface, including its modes of operation and pin configuration. The document emphasizes the importance of data transfer between microprocessors and external devices, highlighting various operational modes for effective communication.

Uploaded by

Ranju samanta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

UNIT-III

I/O INTERFACE
Introduction:

Any application of a microprocessor based system requires the transfer of data


between external circuitry to the microprocessor and microprocessor to the external circuitry.
User can give information to the microprocessor based system using keyboard and user can
see the result or output information from the microprocessor based system with the help of
display device. The transfer of data between keyboard and microprocessor, and
microprocessor and display device is called input/output data transfer or I/O data transfer.
This data transfer is done with the help of I/O ports.

Input port:

It is used to read data from the input device such as keyboard. The simplest form of
input port is a buffer. The input device is connected to the microprocessor through buffer,
as shown in the fig.1. This buffer is a tri-state buffer and its output is available only when
enable signal is active. When microprocessor wants to read data from the input device
(keyboard), the control signals from the microprocessor activates the buffer by asserting
enable input of the buffer. Once the buffer is enabled, data from the input device is available
on the data bus. Microprocessor reads this data by initiating read command.

Output port:
It is used to send data to the output device such as display from the
microprocessor. The simplest form of output port is a latch. The output device is connected
to the microprocessor through latch, as shown in the fig.2. When microprocessor wants to
send data to the output device is puts the data on the data bus and activates the clock signal
of the latch, latching the data from the data bus at the output of latch. It is then available at the
output of latch for the output device.

Serial and Parallel Transmission:

In telecommunications, serial transmission is the sequential transmission of signal


elements of a group representing a character or other entity of data. Digital serial
transmissions are bits sent over a single wire, frequency or optical path sequentially.
Because it requires less signal processing and less chance for error than parallel
transmission, the transfer rate of each individual path may be faster. This can be used
over longer distances as a check digit or parity bit can be sent along it easily.
In telecommunications, parallel transmission is the simultaneous transmission of the
signal elements of a character or other entity of data. In digital communications, parallel
transmission is the simultaneous transmission of related signal elements over two or more
separate paths. Multiple electrical wires are used which can transmit multiple bits
simultaneously, which allows for higher data transfer rates than can be achieved with
serial transmission. This method is used internally within the computer, for example the
internal buses, and sometimes externally for such things as printers, The major issue with this
is "skewing" because the wires in parallel data transmission have slightly different
properties (not intentionally) so some bits may arrive before others, which may corrupt the
message. A parity bit can help to reduce this. However, electrical wire parallel data
transmission is therefore less reliable for long distances because corrupt transmissions are far
more likely.
Interrupt driven I/O:

In this technique, a CPU automatically executes one of a collection of special


routines whenever certain condition exists within a program or a processor system. Example
CPU gives response to devices such as keyboard, sensor and other components when they
request for service. When the CPU is asked to communicate with devices, it services the
devices. Example each time you type a character on a keyboard, a keyboard service routine
is called. It transfers the character you typed from the keyboard I/O port into the processor
and then to a data buffer in memory.
The interrupt driven I/O technique allows the CPU to execute its main program and
only stop to service I/O device when it is told to do so by the I/O system as shown in fig.3.
This method provides an external asynchronous input that would inform the processor that it
should complete whatever instruction that is currently being executed and fetch a new
routine that will service the requesting device. Once this servicing is completed, the
processor would resume exactly where it left off.

An analogy to the interrupt concept is in the classroom, where the professor serves as
CPU and the students as I/O ports. The classroom scenario for this interrupt analogy will be
such that the professor is busy in writing on the blackboard and delivering his lecture.
The student raises his finger when he wants to ask a question (student requesting for
service). The professor then completes his sentence and acknowledges student̏ s request by
saying “YES” (professor acknowledges the interrupt request). After acknowledgement from
the professor, student asks the question and professor gives answer to the question
(professor services the interrupt). After that professor continues its remaining lecture form
where it was left.

PIO 8255:

The parallel input-output port chip 8255 is also called as programmableperipheral


input-output port. The Intel̏ s 8255 are designed for use with Intel̏ s 8-bit, 16-bit and
higher capability microprocessors. It has 24 input/output lineswhich may be individually
programmed in two groups of twelve lines each, orthree groups of eight lines.
The two groups of I/O pins are named as Group A and Group B. Each of thesetwo
groups contains a subgroup of eight I/O lines called as 8-bit port and anothersubgroup of four
lines or a 4-bit port. Thus Group A contains an 8-bit port Aalong with a 4-bit port C upper.
The port A lines are identified by symbols PA0-PA7 while the port C lines are
identified as PC4-PC7 similarly. Group B contains an 8-bit port B, containing lines PB0- PB7
and a 4-bit port C with lower bits PC0-PC3. The port C upper and port C lower can be used
in combination as an 8-bit port C. Both the port Cs is assigned the same address. Thus one
may have either three 8-bit I/O ports or two 8-bit and two 4-bit I/O ports from 8255. All of
these ports can function independently either as input or as output ports. This can be achieved
by programming the bits of an internal register of 8255 called as control word register
(CWR). The internal block diagram and the pin configuration of 8255 are shown in figs.

The 8-bit data bus buffer is controlled by the read/write control logic. The read/write
control logic manages all of the internal and external transfer of both data and control words.
RD, WR, A1, A0 and RESET are the inputs, provided by the microprocessor to
READ/WRITE control logic of 8255. The 8-bit, 3-state bidirectional buffer is used to
interface the 8255 internal data bus with the external system data bus. This buffer receives
or transmits data upon the execution of input or output instructions by the microprocessor.
The control words or status information is also transferred through the buffer.

Pin Diagram of 8255A


The pin configuration of 8255 is shown in fig.

· The port A lines are identified by symbols PA0-PA7 while the port C lines are
· Identified as PC4-PC7. Similarly, Group B contains an 8-bit port B, containing
lines PB0-PB7 and a 4-bit port C with lower bits PC0- PC3. The port C upper and
port C lower can be used in combination as an 8-bit port C.

· Both the port C is assigned the same address. Thus one may have either three
8-bit I/O ports or two 8-bit and two 4-bit ports from 8255. All of these ports can
function independently either as input or as output ports. This can be achieved
by programming the bits of an internal register of 8255 called as control word
register (CWR).
· The 8-bit data bus buffer is controlled by the read/write control logic. The read/write
control logic manages all of the internal and external transfers of both data and
control words.
· RD,WR, A1, A0 and RESET are the inputs provided by the microprocessor to the
READ/ WRITE control logic of 8255. The 8-bit, 3-state bidirectional buffer is
used to interface the 8255 internal data bus with the external system data bus.
· This buffer receives or transmits data upon the execution of input or output
instructions by the microprocessor. The control words or status information is also
transferred through the buffer.

The signal description of 8255 is briefly presented as follows:

· PA7-PA0: These are eight port A lines that acts as either latched output or buffered
input lines depending upon the control word loaded into the control word
register.
· PC7-PC4: Upper nibble of port C lines. They may act as either output latches or
input buffers lines.
· This port also can be used for generation of handshake lines in mode1 or mode2.
· PC3-PC0: These are the lower port C lines; other details are the same as PC7-
PC4 lines.
· PB0-PB7: These are the eight port B lines which are used as latched output lines or
buffered input lines in the same way as port A.
· RD: This is the input line driven by the microprocessor and should be low to
indicate read operation to 8255.
· WR: This is an input line driven by the microprocessor. A low on this line
indicates write operation.
· CS: This is a chip select line. If this line goes low, it enables the 8255 to respond to
RD and WR signals, otherwise RD and WR signal are neglected.
· D0-D7: These are the data bus lines those carry data or control word to/from the
microprocessor.
· RESET: Logic high on this line clears the control word register of 8255. All ports are
set as input ports by default after reset.
· A1-A0: These are the address input lines and are driven by the microprocessor.
· These lines A1-A0 with RD, WR and CS from the following operations for 8255.
These address lines are used for addressing any one of the four registers, i.e.
three ports and a control word register as given in table below.

In case of 8086 systems, if the 8255 is to be interfaced with lower order data bus, the A0
and A1 pins of 8255 are connected with A1 and A2 respectively.
Modes of Operation of 8255

· These are two basic modes of operation of 8255. I/O mode and Bit Set-Reset
mode (BSR).
· In I/O mode, the 8255 ports work as programmable I/O ports, while in BSR mode only
port C (PC0-PC7) can be used to set or reset its individual port bits.
· Under the I/O mode of operation, further there are three modes of operation of
8255, so as to support different types of applications, mode 0, mode 1 and mode 2.
· BSR Mode: In this mode any of the 8-bits of port C can be set or reset depending on
D0 of the control word. The bit to be set or reset is selected by bit select flags D3, D2
and D1 of the CWR as given in table.

I/O Modes:

a) Mode 0 (Basic I/O mode): This mode is also called as basic input/output Mode. This
mode provides simple input and output capabilities using each of the threeports. Data can be
simply read from and written to the input and output portsrespectively, after appropriate
initialization.

The salient features of this mode are as listed below:

1. Two 8-bit ports (port A and port B) and two 4-bit ports (port C upper and lower) are
available. The two 4-bit ports can be combined used as a third 8-bit port.
2. Any port can be used as an input or output port.
3. Output ports are latched. Input ports are not latched.
4. A maximum of four ports are available so that overall 16 I/O configurations are
possible.
· All these modes can be selected by programming a register internal to 8255known as
CWR.
· The control word register has two formats. The first format is valid for I/O modes
of operation, i.e. modes 0, mode 1 and mode 2 while the second format is valid for
bit set/reset (BSR) mode of operation.

These formats are shown in following fig.


b) Mode 1: (S t ro b e d input/output mode) in this mode the handshaking control the
input and output action of the specified port. Port C lines PC0-PC2, provide strobe or
handshake lines for port B. This group which includes port B and PC0-PC2 is called as
group B for Strobed data input/output. Port C lines PC3-PC5 provides strobe lines for port
A. This group including port A and PC3-PC5 from group A. Thus port C is utilized for
generating handshake signals.

The salient features of mode 1 are listed as follows:

1. Two groups – group A and group B are available for strobed data transfer.
2. Each group contains one 8-bit data I/O port and one 4-bit control/data port.
3. The 8-bit data port can be either used as input and output port. The inputs and outputs
both are latched.
4. Out of 8-bit port C, PC0-PC2 are used to generate control signals for port B
andPC3-PC5 are used to generate control signals for port A. the lines PC6, PC7
may be used as independent data lines.

The control signals for both the groups in input and output modes are explained as
follows:

Input control signal definitions (mode 1):

• STB (Strobe input) – If this lines falls to logic low level, the data available at 8-
bit input port is loaded into input latches.
• IBF (Input buffer full) – If this signal rises to logic 1, it indicates that data has
been loaded into latches, i.e. it works as an acknowledgement. IBF is set by a low
on STB and is reset by the rising edge of RD input.
• INTR (Interrupt request) – This active high output signal can be used to
interrupt the CPU whenever an input device requests the service. INTR is set by a
high STB pin and a high at IBF pin. INTE is an internal flag that can be
controlled by the bit set/reset mode of either PC4 (INTEA) or PC2 (INTEB) as
shown in fig.
• INTR is reset by a falling edge of RD input. Thus an external input device can be
request the service of the processor by putting the data on the bus and
sending the strobe signal.

Output control signal definitions (mode 1):

• OBF (Output buffer full) – This status signal, whenever falls to low, indicates
that CPU has written data to the specified output port. The OBF flip- flop will
beset by a rising edge of WR signal and reset by a low going edge at the ACK
input.
• ACK (Acknowledge input) – ACK signal acts as an acknowledgement to be given
by an output device. ACK signal, whenever low, informs the CPU that the data
transferred by the CPU to the output device through the port is received by the
output device.
• INTR (Interrupt request) – Thus an output signal that can be used to interrupt
the CPU when an output device acknowledges the data received from the
CPU.INTR is set when ACK, OBF and INTE are 1. It is reset by a

Falling edge on WR input. The INTEA and INTEB flags are controlled by the bit set-
reset mode ofPC6 and PC2 respectively.
c) Mode 2 (Strobed bidirectional I/O): This mode of operation of 8255 is also called as
strobed bidirectional I/O. This mode of operation provides 8255 with additional features for
communicating with a peripheral device on an 8-bit data bus. Handshaking signals are
provided to maintain proper data flow and synchronization between the data transmitter
and receiver. The interrupt generation and other functions are similar to mode 1.

In this mode, 8255 is a bidirectional 8-bit port with handshake signals. The Rd and WR
signals decide whether the 8255 is going to operate as an input port or output port.

The Salient features of Mode 2 of 8255 are listed as follows:

1. The single 8-bit port in group A is available.


2. The 8-bit port is bidirectional and additionally a 5-bit control port is available.
3. Three I/O lines are available at port C.( PC2 – PC0 )
4. Inputs and outputs are both latched.

5. The 5-bit control port C (PC3-PC7) is used for generating / accepting


handshake signals for the 8-bit data transfer on port A.
Control signal definitions in mode 2:

· INTR – (Interrupt request) As in mode 1, this control signal is active high and
is used to interrupt the microprocessor to ask for transfer of the next data byte
to/from it. This signal is used for input (read) as well as output (write) operations.
· Control Signals for Output operations:
· OBF (Output buffer full) – This signal, when falls to low level, indicates that
the CPU has written data to port A.
· ACK (Acknowledge) This control input, when falls to logic low level,
Acknowledges that the previous data byte is received by the destination and
next byte may be sent by the processor. This signal enables the internal tristate
buffers to send the next data byte on port A.
· INTE1 ( A flag associated with OBF ) This can be controlled by bit set/resetmode
with PC6.

Control signals for input operations:

· STB (Strobe input)a low on this line is used to strobe in the data into the input
Latches of 8255.
· IBF (Input buffer full) when the data is loaded into input buffer, this signal rises to
logic „1̏ . This can be used as an acknowledge that the data has been received by
the receiver.
· The waveforms in fig show the operation in Mode 2 for output as well as input
port.
· Note: WR must occur before ACK and STB must be activated before RD.

· The following fig shows a schematic diagram containing an 8-bit bidirectional


port, 5-bit control port and the relation of INTR with the control pins. Port B can
either be set to Mode 0 or 1 with port A( Group A ) is in Mode 2.
· Mode 2 is not available for port B. The following fig shows the control word.
· The INTR goes high only if IBF, INTE2, STB and RD go high or OBF,
· INTE1, ACK and WR go high. The port C can be read to know the status of the
peripheral device, in terms of the control signals, using the normal I/O
instructions.
Interfacing Analog to Digital Data Converters:

· In most of the cases, the PIO 8255 is used for interfacing the analog to digital
converters with microprocessor.
· We have already studied 8255 interfacing with 8086 as an I/O port, in previous
section. This section we will only emphasize the interfacing techniques of analog to
digital converters with 8255.
· The analog to digital converters is treated as an input device by the microprocessor
that sends an initializing signal to the ADC to start the analogy to digital data
conversation process. The start of conversation signal is a pulse of a specific
duration.
· The process of analog to digital conversion is a slow
· Process and the microprocessor have 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. The set asks 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 caseof 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.
· General algorithm for ADC interfacing contains the following steps:
· Ensure the stability of analog input, applied to the ADC.
· Issue start of conversion pulse to ADC
· Read end of conversion signal to mark the end of conversion processes.
· Read digital data output of the ADC as equivalent digital output.
· 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 as ample 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.

ADC 0808/0809:

· 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 - ADD A, ADD B,
ADD C, as shown. Using these address inputs, multichannel data
acquisition system can be designed using a single ADC. The CPU may
drive these lines using output port lines in case of multichannel
applications. In case of single input applications, these may be hardwired to
select the proper input.
· There are unipolar analog to digital converters, i.e. they are able to convert
only positive analog input voltage to their digital equivalent. These chips do
not contain any internal sample and hold circuit.
· If one needs a sample and hold circuit for the conversion of fast signal
into equivalent digital quantities, it has to be externally connected at each
of the analog inputs.

Fig (1) and Fig (2) show the block diagrams and pin diagrams for ADC 0808/0809.

Table.1

Analog I/P 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

Fig.1 Block Diagram of ADC 0808/0809


Fig.2 Pin Diagram of ADC 0808/0809

Some Electrical Specifications Of The ADC 0808/0809 Are Given In Table.2.

Table.2

The Timing Diagram Of Different Signals Of Adc0808 Is Shown In Fig.3


Fig.3 Timing Diagram Of ADC 0808.

Interfacing ADC0808 with 8086

Interfacing Digital To Analog Converters:

The digital to analog converters convert binary numbers into their analog
equivalent voltages. The DAC find applications in areas like digitally controlled gains,
motor speed controls, programmable gain amplifiers, etc.

DAC0800 8-bit Digital to Analog Converter

· The DAC 0800 is a monolithic 8-bit DAC manufactured by National Semiconductor.


· It has settling time around 100ms and can operate on a range of power supply voltages
i.e. from 4.5V to +18V.
· Usually the supply V+ is 5V or +12V.
· The V-pin can be kept at a minimum of -12V.

Pin Diagram of DAC 0800

Interfacing DAC0800 with 8086 Ad


7523 8-Bit Multiplying DAC:
· Intersil̏ s AD 7523 is a 16 pin DIP, multiplying digital to analog converter,
containing R-2R ladder(R=10KΩ) for digital to analog conversion along with
single pole double through NMOS switches to connect the digital inputs to the
ladder.

Pin Diagram of AD7523

· The supply range extends from +5V to +15V , while Vref may be anywhere
between -10V to +10V. The maximum analog output voltage will be +10V,
when all the digital inputs are at logic high state. Usually a Zener is connected
between OUT1 and OUT2 to save the DAC from negative transients.
· An operational amplifier is used as a current to voltage converter at the output
of AD 7523 to convert the current output of AD7523 to a proportional output
voltage.

· It also offers additional drive capability to the DAC output. An external feedback
resistor acts to control the gain. One may not connect any external feedback
resistor, if no gain control is required.

Interfacing AD7523 with 8086 Stepper


Motor Interfacing:
· A stepper motor is a device used to obtain an accurate position control of rotating
shafts. It employs rotation of its shaft in terms of steps, rather than continuous
rotation as in case of AC or DC motors. To rotate the shaft of the stepper motor, a
sequence of pulses is needed to be applied to the windings of the stepper motor, in a
proper sequence.
· The number of pulses required for one complete rotation of the shaft of the stepper
motor is equal to its number of internal teeth on its rotor. The stator teeth and the
rotor teeth lock with each other to fix a position of the shaft.
· With a pulse applied to the winding input, the rotor rotates by one teeth position or an
angle x. The angle x may be calculated as:

X=3600/no. of rotor teeth


· After the rotation of the shaft through angel x, the rotor locks itself with the next
tooth in the sequence on the internal surface of stator.
· The internal schematic of a typical stepper motor with four windings is shown in
fig.1.
· The stepper motors have been designed to work with digital circuits. Binary
level pulses of 0-5V are required at its winding inputs to obtain the rotation of
shafts. The sequence of the pulses can be decided, depending upon the required
motion of the shaft.
· Fig.2 shows a typical winding arrangement of the stepper motor.
· Fig.3 shows conceptual positioning of the rotor teeth on the surface of rotor, for a
six teeth rotor.

Fig.1 Internal schematic of a four winding stepper motor

Fig.2 Winding arrangement of a stepper motor.

Fig.3 Stepper motor rotor

· The circuit for interfacing a winding Wn with an I/O port is given in fig.4. Each of the
windings of a stepper motor needs this circuit for its interfacing with the output
port. A typical stepper motor may have parameters like torque 3 Kg-cm, operating
voltage 12V, current rating 0.2 A and a step angle 1.80 i.e. 200 steps/revolution
(number of rotor teeth).
· A simple schematic for rotating the shaft of a stepper motor is called a wave
scheme. In this scheme, the windings Wa, Wb, Wc and Wd are applied with the
required voltages pulses, in a cyclic fashion. By reversing the sequence of excitation,
the direction of rotation of the stepper motor shaft may be reversed.
· Table.1 shows the excitation sequences for clockwise and anticlockwise rotations.
Another popular scheme for rotation of a stepper motor shaft applies pulses to two
successive windings at a time but these are shifted only by one position at a time. This
scheme for rotation of stepper motor shaft is shown in table2.

Fig.4 interfacing stepper motor winding.

Table.1 Excitation sequence of a stepper motor using wave switching scheme.

Motion step A B C D
1 1 0 0 0
2 0 1 0 0
Clock 3 0 0 1 0
Wise Direction 4 0 0 0 1
5 1 0 0 0
1 1 0 0 0
2 0 0 0 1
Anti clock
wise 3 0 0 1 0
Direction 4 0 1 0 0
5 1 0 0 0
Table.2 An alternative scheme for rotating stepper motor shaft

Motion step A B C D
1 0 0 1 1
2 0 1 1 0
Clock wise 3 1 1 0 0
Direction 4 1 0 0 1
5 0 0 1 1
1 0 0 1 1
2 1 0 0 1
Anti clock
wise 3 1 1 0 0
Direction 4 0 1 1 0
5 0 0 0 0

Keyboard Interfacing

· In most keyboards, the key switches are connected in a matrix of Rows and
Columns.
· Getting meaningful data from a keyboard requires three major tasks:
1. e t e c t a k e y p r e s s
2. D e b o u n c e t h e k e y p r e s s .
3. Encode the keypress (produce a standard code for the pressed
key).
· Logic „0̏ is read by the microprocessor when the key is pressed.

Key Debounce:
Whenever a mechanical push-bottom is pressed or released once,the mechanical
components of the key do not change the positionsmoothly; rather it generates a transient
response. These may be interpreted as the multiple pressures and responded accordingly.
· The rows of the matrix are connected to four output Port lines, &columns are
connected to four input Port lines.
· When no keys are pressed, the column lines are held high by the pull-up resistors
connected to +5v.
· Pressing a key connects a row & a column.
· To detect if any key is pressed is to output 0̏ s to all rows & then check columns to
see it a pressed key has connected a low (zero) to a column.
· Once the columns are found to be all high, the program enters another loop, which
waits until a low appears on one of the columns i.e indicating a key press.
· A simple 20/10 m sec delay is executed to debounce task.
· After the debounce time, another check is made to see if the key is still pressed. If
the columns are now all high, then no key is pressed & the initial detection was
caused by a noise pulse.
· To avoid this problem, two schemes are suggested:
1. Use of Bistable multivibrator at the output of the key to debounce it.
2. The microprocessor has to wait for the transient period (at least
for 10 ms), so that the transient response settles down and reaches a steady
state.
· If any of the columns are low now, then the assumption is made that it was a valid
key press.

· The final task is to determine the row & column of the pressed key &convert this
information to Hex-code for the pressed key.
· The 4-bit code from I/P port & the 4-bit code from O/P port (row &column) are
converted to Hex-code.
Interfacing 4x4 keyboard

Display Interface
Interfacing multiplexed 7-segment display
Interfacing with Advanced devices
4.1 MEMORY AND I/O INTERFACING
(Ref: Interfacing through Microprocessors by K. Subba Rao, Hi-tech publishers, P. 163-166)

4.1.1 I/O Interface


Any application of a microprocessor system requires the transfer of data between
microprocessor and external environment and also within the microprocessor. This is known as Input/output.
There are three different ways that the data transfer can take place. They are
(1) Program controlled I/O
(2) Interrupt Program Controlled I/O
(3) Hardware controlled I/O

In program controlled I/O data transfer scheme the transfer of data is completely under the control
of the microprocessor program. In this case an I/O operation takes place only when an I/O transfer instruction
is executed.
In an interrupt program controlled I/O an external device indicates directly to the microprocessor its
readiness to transfer data by a signal at an interrupt input of the microprocessor. When microprocessor
receives this signal the control is transferred to ISS (Interrupt service subroutine) which performs the data
transfer.
Hardware controlled I/O is also known as direct memory access DMA. In this case the data transfer
takes place directly between an I/O device and memory but not through microprocessors. Microprocessor
only initializes the process of data transfer by indicating the starting address and the number of words to be
transferred.
The instruction .set of any microprocessor contains instructions that transfer information to an I/O
device and to read information from an I/O device. In 8086 we have IN, OUT instructions for this purpose.
OUT instruction transfers information to an I/O device whereas IN instruction is used to read information
from an I/O device. Both the instructions perform the data transfer using accumulator AL or AX. The I/O
address is stored in register DX.
The port number is specified along with IN or OUT instruction. The external I/O interface decodes to
find the address of the I/O device. The 8 bit fixed port number appears on address bus A0 - A7 with A8 - A15
all zeros. The address connections above A15 are undefined for an I/O instruction. The 16 bit variable port
number appears on address connections A0 - A15. The above notation indicates that first 256 I/O port
addresses 00 to FF are accessed by both the fixed and variable I/O instructions. The I/O addresses from 0000
to FFFF are accessed by the variable I/O address.
I/O devices can be interfaced to the microprocessors using two methods. They are I/O mapped I/O
and memory mapped I/O. The I/O mapped I/O is also known as isolated I/O or
direct I/O. In I/O mapped I/O the IN and OUT instructions transfer data between the accumulator or memory
and I/O device. In memory mapped I/O the instruction that refers memory can perform the data transfer.

I/O mapped I/O is the most commonly used I/O transfer technique. In this method I/O locations are
placed separately from memory. The addresses for isolated I/O devices are separate from memory. Using this
method user can use the entire memory. This method allows data transfer only by using instructions IN, OUT.

The pins M/ IO and W/R are used to indicate I/O read or an I/O write operations. The signals on these lines
indicate that the address on the address bus is for I/O devices.
Memory mapped I/O does not use the IN, OUT instruction it uses only the instruction that transfers
data between microprocessor and memory. A memory mapped I/O device is treated as memory location. The
disadvantage in this system is the overall memory is reduced. The advantage of this system is that any
memory transfer instruction can be used for data transfer and control signals like I/O read and I/O write are
not necessary which simplify the hardware.

4.1.2 Memory interfacing


Memory is an integral part of a microcomputer system. There are two main types of memory.
(i) Read only memory (ROM): As the name indicates this memory is available only for reading
purpose. The various types available under this category are PROM, EPROM, EEPROM which
contain system software and permanent system data.
(ii) Random Access memory (RAM): This is also known as Read Write Memory. It is a volatile
memory. RAM contains temporary data and software programs generally for different
applications.

While executing particular task it is necessary to access memory to get instruction codes and
data stored in memory. Microprocessor initiates the necessary signals when read or write operation is to be

You might also like