MPMC Notes 2
MPMC Notes 2
programmable peripheral interface, Interfacing switches and LEDS, Interfacing seven segment
displays, software and hardware interrupt applications, Intel 8251 USART architecture and
interfacing, Intel 8237a DMA controller, stepper motor, A/D and D/A converters, Need for 8259
programmable interrupt controllers.
Form the above block diagram it is noticed that any kind of I/O devices could
be connected with three ports like Port A, Port B, Port C. due to this features
buffer and latch devices are not needed for particular input or output
application so, user has flexibility to use same ports as input or output
application. Another advantage of this chip, that it can be operated in three
different modes which are basically not included in simple I/O interfacing;
these different types of operation extended the data transfer policies.
Functions of each block and pins: Data Bus Buffer- The tri-state
bidirectional 8 bit buffer is used to interface the 8255A to the microprocessor
data bus (D0-D7). Data is transmitted or received by buffer upon the
execution of input or output instructions by the CPU. Control word and status
word also transferred through this data bus buffer.
Read write control logic- The function of this block is to manage all the
internal and external transfers of both data and control or status word. This
block also handles user information regarding operational mode selection,
configuration of ports as an input or output; all of this information stored in
8-bit control word register (CWR). The details of each pin connected with this
block are described below,
𝑪 𝑺 (Chip Select)- A “Low” on this input pin enables the communication
between the 8085 and MPU.
A0 and A1 - These are the address lines of 8255 which are directly
connected to the MPU lower address lines (A0, A1). In conjunction with chip
select, control the selection of one of the three ports or the control word
register has been made. The bit combination of these signals are shown
bellow-
D6 & D5 These are used to set port A mode. for 00, it is m0 mode, for 01, it is m2
mode and 10 or 11, it is m2 mode.
D4 1 when port A is taking input, 0 when port A is sending output.
D3 1 when higher nibble of port C is taking input, and 0 when higher nibble is
sending output.
D2 It tells the mode of Port B. For 0, it is m0 mode, and for 1, it is m1 mode.
D0 1 when lower nibble of port C is taking input, and 0 when lower nibble is
sending output.
3.2 Interfacing switches and LEDS
Example 1:- Interface an 8255 chip with 8086 to work as an I/O port.
Initialize port A as output port, Port B as I/P port and Port C as O/P port. Port
A address should be 0740H. Write an ALP to sense switch positions SW0–SW7
connected at port B. The sensed pattern is to be displayed on port A, to which
8 LED's are connected, while port C lower displays number of on switches out
of the total eight switches ?
The 8255 is to be interfared with lower order data bus; i.e. D0-D7.
The A0 and A1 pins of 8255 are connected to A1 and A2 pins of the
microprocessor respectively. We will use absolute decoding scheme that uses
all the 16 address lines.
For deriving the device address pulse. Out of A0– A15 lines, two
address lines A2 and A1 are directly required by 8255 for three port and CWR
address decoding. Hence only A3 to A15 are used for decoding addresses.
Circuit diagram, the 8086 is assumed to be in the maximum mode so
that IORD and I OWR are readily available.
3.3 Interfacing seven segment displays,
Example 3:- Interface an 8255 with 8086 at 80H as an I/O address of Port A.
Interface five 7 segment displays with the 8255. Write an ALP to display 1, 2,
3, 4 and 5 over the 5 displays continuously as per their positions starting with
1 at the least significant position ?
3.4 software and hardware interrupt applications
Hardware interrupt-
These interrupts occur as signals on the external pins of the
microprocessor. 8086 has two pins to accept hardware interrupts, NMI
and INTR.
Software interrupt-
These interrupts are caused by writing the software interrupt instruction
INT n where ‘n’ can be any value from 0 to 255 (00H to FFH). Hence all
256 interrupts can be invoked by software.
Applications of interrupts:
1. Applications of interrupts include the following: system timers, disk I/O,
power-off signals, and traps.
2. Other interrupts exist to transfer data bytes using UARTs or Ethernet;
sense key-presses; or anything else the equipment must do.
3. Another typical use is to generate periodic interrupts by dividing the
output of a crystal oscillator and having an interrupt handler count the
interrupts in order for a processor to keep time.
4. These periodic interrupts are often used by the OS's task scheduler to
reschedule the priorities of running processes.
5. Some older computers generated periodic interrupts from the power
line frequency because it was controlled by the utilities to eliminate
long-term drift of electric clocks.
6. For example, a disk interrupt signals the completion of a data transfer
from or to the disk peripheral; a process waiting to read or write a file
starts up again.
7. As another example, a power-off interrupt predicts or requests a loss of
power, allowing the computer equipment to perform an orderly shut-
down.
8. Also, interrupts are used in type ahead features for buffering events
like keystrokes.
3.5 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 uni polar 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.
Table.1
Address lines
Analog I/P 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
Some Electrical Specifications Of The ADC 0808/0809 Are Given In Table.2.
3.6 DAC 0808 Interfacing to 8086
The maximum input digital signal will have an analog value which
is equal to reference analog value minus resolution.
The digital-to-analog converters can be broadly classified into
three categories, and they are
• Currentoutput
• Voltageoutput
• Multiplyingtype
The current output DAC provides an analog current as output
signal.In voltage output DAC, the analog current signal is
internally converted to voltage signal.
3.7 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.
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.
3.8 8251 USART
8251 USART is a universal synchronous and asynchronous controller
designed by Intel basically to facilitate communication.USART stands
for Universal Synchronous and Asynchronous Receiver Transmitter and
functions as an intermediary that allows serial and parallel communication
between the microprocessor and the peripheral devices.
We know that microprocessors allow parallel communication. And in
parallel communication, the number of cables required for data transmission
is equal to the number of bits to be transmitted per cycle.
Thus the approach of transmitting data parallelly to long distance is cost-
ineffective.
So, to reduce the overall cost of the system despite parallel data
communication between the processor and peripheral devices, the serial
transfer of data is permitted.
Hence for this purpose, USART acts as a mediator between the
processor and peripheral devices so, that the parallel data from the processor
can be converted into serial data and efficiently transferred to the peripheral
devices.
In a similar way, the serial data from the peripheral devices is
converted by the USART into the parallel form so that it can be accepted by
the processor.
Also, it allows both synchronous and asynchronous transmission and
reception thus is called so.Architecture and Working of 8251 USART
The figure below shows the architectural representation of 8251:
Let us
now understand the operation performed by each unit in detail:
1. Data Bus Buffer: It basically interfaces the 8251 with the internal system
buses of the processor.
The data bus buffer has 8-bit bidirectional data bus that allows the transfer of
data bytes, status or command word between the processor and external
devices.
2. Read/Write Control Logic: This functional unit generates a control signal
for the operation of 8251 according to the signal present in the control bus of
the processor. Basically, it performs decoding operation of the control signal
produced by the processor, so that respective operation can be performed by
the USART.
The control formats for system operation is stored in control and command
word registers present in the read/write logic unit.
CS: It is chip select. A low signal at this pin shows that processor has
selected 8251 in order to communicate with the peripheral devices.
C/D: As the system has control, status and data register. So, when a high
signal is present at this pin then control or status register is addressed.
While in case of low signal data register is addressed.
RD and WR: Both read and write are active low signal pins. A low signal at
RD shows that the processor is reading the control, status or data bytes
from the 8251. While at WR indicates the write operation over the data
bus of 8251.
CLK and RESET: CLK stands for clock and it produces the internal timing
for the device. While an active high signal at the RESET pin puts the 8251
in the idle mode
3. Transmit Buffer: This unit is used to change the parallel data received
from the CPU into serial data by inserting the necessary framing information.
Once the data is transformed into serial form, then in order to transmit it to
the external devices, it is provided to the TxD pin of the 8251.
This unit consists of 2 registers. These are as follows:
Buffer register: Basically the data provided by the processor is stored in
the buffer register. As we know that initially, the CPU provides parallel
data to 8251. So, the processor loads the parallel data to the buffer
register. Further, this data is fed to the output register.
Output register: The parallel data from the buffer register is fed to the
empty output register.
This register changes the 8-bit parallel data into a stream of serial bits.
Then further the serial data is provided at the TxD pin so as to have its
transfer to the peripheral device.
4. Transmit Control: As the name of the unit is itself indicating that it is
controlling the transmission action. And it does so by accepting and sending
signals both externally and internally.
The various control signal generated by this unit are as given below:
TxRDY: It implies transmit ready. This signal is used to notify the
processor that the buffer register of the 8251 is empty and ready to accept
the data.
The status read operation is utilized by the processor in order to check the
presence of the signal.
TxE: This stands for transmitter empty. It is an active high signal that
indicates that the output buffer is empty and thus data received from the
processor can be loaded to it for conversion.
TxC: It stands for transmitter clock and is an active low pin. It controls the
rate of character transmission by the USART.
However, 8251 offers programmable clock rate. As by writing appropriate
mode word in the mode set register the clock division can be programmed.
5. Receive Buffer: This unit takes the serial data from the external devices,
changes the serial data into the parallel form so that it can be accepted by
the processor. It consists of 2 registers: receiver input register and buffer
register.
When the external device is ready to send the data to the 8251 then it sends
a low signal to the RxD line of the 8251. In asynchronous mode, once 8251
receives a low signal it considers that signal as start bit of the data.
6. Receiver Control
This unit controls the operation of the receiver buffer. It manages the data
reception, along with that it also detects the presence of false start bit, error
in parity bit, framing errors etc.
RxRDY: It stands for receiver ready. When this signal goes high then it
indicates that the receiver buffer register is holding the data and is ready
to transfer it to the processor. Once the CPU reads the data sent by the
8251 then this pin is reset.
RxC: It stands for receiver clock. This clock signalling controls the rate at
which the 8251 receives the data in the synchronous mode of operation. It
is provided by the modem and is equal to the baud rate.
While asynchronous mode offers the clock rate as 1, 16 or 64 times of the
baud rate as it is programmable.
7. Modem Control: This unit of 8251 holds input and output control signals
that simplify the operation of the whole system. The control circuitry for
handing various signals is provided by the modem control unit. It includes
DTS, RTS, DTR and CTS.
These are all active low signals.
DSR: Stands for data set ready and the signal is used to check whether
the data set is ready or not when the processor is in the urge of
communication.
DTR: Implies data terminal ready. An active-low signal at this pin shows
that the 8251 is now ready to accept the data from the processor.
RTS: It stands for the request to send. A low signal shows an assertion for
data transmission.
CTS: Clear to send. When 8251 receives a low signal at this pin then it
clears all the data present in the modem in order to allow further
communication.
3.9 INTERFACING 8251A TO 8086 PROCESSOR
• The chip select for I/O mapped devices are generated by using a 3-to-8
decoder.
• The address lines A5, A6 and A7 are decoded to generate eight chip select
signals (IOCS-0 to IOCS-7) and in this, the chip select signal IOCS-2 is used
to select 825lA.
• The address line A0 and the control signal M/IO(low) are used as enable for
decoder.
• The line A1 of 8086 is connected to C/D(low) of 8251A to provide the
internal addresses.
• The lines D0 – D7 connected to D0 – D7 of the processor to achieve
parallel data transfer.
In 8251A the transmission and reception baud rates can be different or same.
• The TTL logic levels of the serial data lines and the control signals necessary
for serial transmission and reception are converted to RS232 logic levels
using MAX232 and then terminated on a standard 9-pin D-.type connector.
• The device, which requires serial communication with processor, can be
connected to this 9-pin D-type connector using 9-core cable.
• The signals TxEMPTY, TxRDY and RxRDY can be used as interrupt signals to
initiate interrupt driven data transfer scheme between processor and 8251 A.
• The I/O addresses allotted to the internal devices of 8251A are listed in
table.
3.10 8237 DMA
Direct Memory Access (DMA) is an I/O technique commonly used for
high-speed data transfer; for example , data transfer between memory and a
floppy disk. In DMA, µP releases the control of the buses to a device called
a DMA controller. The controller manages data transfer between memory and
a peripheral under its control, thus bypassing the MPU It introduces two new
signals HOLD (pin 39) and HLDA (pin 38) (Hold acknowledge)
HOLD:This is an active high input signal Pin number 39 The
processor relinquishes (gives up) the buses in the following machine cycle
once the MPU receives the HOLD request All buses are tri-stated and HLDA
(Hold Acknowledge) signal is sent out MPU regains the control of the buses
after HOLD goes low
HLDA:This is an active high output signal Pin number 38 It indicates
that the MPU is giving up the control of the buses
The DMA controller should have I. A data bus II. An address bus III.
Read/Write control signals, and IV. Control signals to disable its role as a
peripheral and to enable its role as a peripheral
1. Figure below shows that how an 8259 can be interfaced with the 8086
microprocessor system in minimum mode. In case of 8086
microprocessor same interfacing diagram can be used except M/I0
signal.
1. The 74LS138 address decoder will assert the CS input of the 8259 when
an I/O base address is FFF0H or FFF2H on the address bus.
2. The A_0 input of the 8259A is used to select one of the two internal
addresses in the device. Ao of the 8259A is connected to system line Al.
So the system addresses for the two internal addresses are FFF0H and
FFF2H.
3. The data lines of an 8259 are connected to the lower half of the system
data bus; because the 8086 expects to receive interrupt types on these
lower eight data lines.
4. RD and WR signals are connected to the system RD and WR lines.
5. The interrupt request signal INT from the 8259 is connected to the
INTR input of the 8086 and INTA from the 8086 is connected to INTA
on the 8259A. As we are using single 8259 in the system SP/EN pin is
tied high and CAS0-CAS2 lines are left open.
6. The eight IR inputs are available for interrupt signals.
7. Cascading :
8. The 8259 can be easily interconnected to get multiple interrupts. Fig
below shows how 8259 can be connected in the cascade mode. In
cascade mode one 8259 is configured in Master mode and other should
be configured in the Slave mode. In this figure 8259 is in the master
mode and others are in slave mode. Each slave 8259 is identified by the
number which is assigned as a part of its initialization. Since the 8086
has only one INTR input, only one of the 8259 INT pins is connected to
the 8086 INTR pin. The 8259 connected directly into the 8086 INTR pm
is referred as the master. The INT pins from other 8259 are connected
to the IR inputs of the master 8259. These cascaded 8259s are referred
as slave. The INTA signal is connected to both master and slave 8259.
9. The cascade pins CAS0 to CAS2 are connected from the master to the
corresponding pins of the slave. For the master these pins function as
outputs, and for the slave these pins function as inputs. The SP/EN
signal is tied high for the master. However it is grounded for the slave.
10. Each 8259A has its own addresses so that command words can
be written to it and status bytes read from it.