Chapter 4
Chapter 4
Depending on the modes that are supported by the hardware, the name of the communication sub-
system will usually include an A if it supports Asynchronous communications, and a S if it
supports Synchronous communications.
Serial transmission
Asynchronous transmission allows data to be transmitted without the sender having to send a
clock signal to the receiver. Instead, the sender and receiver must agree on timing parameters in
advance and special bits are added to each word which is used to synchronize the sending and
receiving units. It is character oriented mode of transmission. Before a character begins the line
must be in its “1” state, called mark state. The transition from the mark state to “0” , or space
,states indicates the beginning of character. When a word is given to the UART for Asynchronous
transmissions, the first bit is ‘0’ and is called the "Start Bit" is added to the beginning of each
word that is to be transmitted. The Start Bit is used to alert the receiver that a word of data is
about to be sent, and to force the clock in the receiver into synchronization with the clock in the
transmitter. Transmission begins with the start bit followed by a character and one or two stop
bits. Usually start bits are low signals and stop bits are continuous high signals. Asynchronous
transmission is easy to implement but less efficient as it requires an extra 2-3 control bits for
every 8 data bits .This method is usually used for low volume transmission.
In most computer systems, the UART (Universal Asynchronous Receiver Transmitter) is connected to
circuitry that generates signals that comply with the EIA RS232-C specification. There is also a CCITT
standard named V.24 that mirrors the specifications included in RS232-C.
RS-232 is defined as the “Interface between data terminal equipment and data communications equipment
using serial binary data exchange.” This definition defines data terminal equipment (DTE) as the
computer, while data communications equipment (DCE) is the modem. A modem cable has pin-to-pin
connections, and is designed to connect a DTE device to a DCE device.
The RS232-C specification defines two types of equipment: the Data Terminal Equipment (DTE) and the
Data Carrier Equipment (DCE). Usually, the DTE device is the terminal (or computer), and the DCE is a
modem. Across the phone line at the other end of a conversation, the receiving modem is also a DCE
device and the computer that is connected to that modem is a DTE device. The DCE device receives
signals on the pins that the DTE device transmits on, and vice versa.
When two devices that are both DTE or both DCE must be connected together without a modem or a
similar media translator between them, a NULL modem must be used. The NULL modem electrically re-
arranges the cabling so that the transmitter output is connected to the receiver input on the other device,
and vice versa. Similar translations are performed on all of the control signals so that each device will see
what it thinks are DCE (or DTE) signals from the other device.
The number of signals generated by the DTE and DCE devices is not symmetrical. The DTE device
generates fewer signals for the DCE device than the DTE device receives from the DCE
This section includes a control logic, six input signals, and three buffer registers: Data
register, control register and status register. The control logic interfaces the chip with MPU,
Input signals
CS – Chip Select: When this signal goes low, the 8251A is selected by the MPU for
communication.
C/D – Control/Data: When this signal is high, the control or status register is addressed;
when it is low, data buffer is addressed. The control register and status register are
differentiated by WR and RD signals.
WR: When this signal is low, the MPU either writes in the control register or sends output
to the data buffer
RD: When this signal goes low, the MPU either reads a status from the status register or
accepts data from data buffer.
RESET: A high on this signal reset 8252A and forces it into the idle mode.
CLK: This is the clock input, usually connected to the system clock for communication
with the microprocessor.
Control Register
The 16-bit register for a control word consist of two independent bytes. : the first byte is
called mode word and the second byte is called the command word. The mode word specifies the
general characteristics of operation such as baud, parity, number of bits etc. But the command
word enables the data transmission and reception. The register can be accessed as an output port
when the Control/Data pin is high.
Status register
This input register checks the ready status of the peripheral. The status word in the status
register provides the information concerning register status and transmission errors.
Data buffer
This bidirectional register can be used as an input and output port when the C/D is low.
CS C/D WR RD Operation
0 0 1 0 MPU reads data from data buffer
The transmitter accepts parallel data from MPU and converts them into serial data. It has two
registers:
The MPU writes a byte in the buffer register, whenever the output register is empty; the contents
of buffer register are transferred to output register. And transmit the data on the TxD pin with
appropriate framing bits. Three output and one input signals are associated with this transmitter
section.
TxRDY: An output signal, indicate the buffer register is empty and the USART is ready to accept
the next data byte.
TxE: An output signal to indicate the output register is empty and the USART is ready to accept
the next data byte.
Receiver section accepts serial data on the RxD pin and converts them to parallel data. This
section has two registers:
When the RxD goes low, the control logic assumes it is a start bit, waits for half bit time, and
samples the line again. If the line is still low, the input register accepts the following data, and
loads it into buffer register at the rate determined by the receiver clock.
RxRDY- receiver Ready: This is an output signal. It goes high when the USART has a character
in the buffer register and is ready to transfer it to the MPU.
RxD- Receive data: Bits are received serially on this line and converted into a parallel byte in the
receiver input register.
RxC- Receiver clock: This is clock signal that controls the rate at which bits are received by the
USART.
Parallel communication is a method of sending several data signals simultaneously over several
parallel channels. It is accomplished by simultaneously transferring bits over separate lines
Parallel communications are used over very short distances; typically inside the computer itself
and to printers. This method, together with the connector, was developed by Centronics and used
by IBM in its first PC. The parallel port greatly increases transfer speeds by using an eight wire
connector which transmits the eight bits in a byte of data simultaneously, thus sending an entire
byte of data in the time it takes to send a single bit in a serial system. This byte of data is
supplemented by several other handshaking signals, each sent on its own wire, which ensures that
data transfer takes place smoothly.
When you need to get digital data from a simple switch, all you have to do is connect
the switch to an I/P port line and read the value.
Likewise, when you need to O/P data to simple LED, all you have to do is connect the
LED to an O/P port and send the value.
The LED is always ready, so you can send data at any time.
When a key is pressed, circuitry on the keyboard sends out the ASCII code for the
pressed key on eight parallel data line , and then sends out a strobe signal on another
line to indicate that valid data is present on the eight data lines.
For higher speed data transfer this method does not work.
The sending system might send data bytes faster than the receiving system could
read them. To prevent this handshake data transfer is required.
The peripheral outputs some parallel data and sends STB signal to MPU.
The MPU detects STB signal on a polled or interrupt basis and reads data byte.
Then the MP sends on ACK signal to the peripheral to indicate that the data has been
read and the peripheral can send to next byte of data.
For data transfers where coordination is required between sending system and the
receiving system, a double handshake is used.
The sending device asserts its STB low to ask “Are you ready?”
The receiving system raises its ACK line high to say “I’m ready”.
The peripheral device then sends the data byte and raises its STB signal high to say
“Here is valid data for you”.
When the receiving system finishes to read the data, receiving system drop its ACK
line low to say “I have data than you and I await your request to send the
next byte of data”.
INTRODUCTION
The 8255A PPI provides three 8 bit input/output ports in one 40 pin package.
The chip can be interfaced directly to the data bus of the processor allowing its function
to be programmed.
DESCRIPTION
It provides 24 I/O lines organized as three 8 bit input/output ports labeled A,B and C.
Port C can be divided in half, with the topmost or bottommost four bits programmed as
inputs or outputs.
Port C can be used as an 8 bit input or output port as two 4 bit ports or to produce
handshake signals for Port A and B.
For example, Port A can be programmed to operate in MODE 2 while Port B in MODE 0.
DESCRIPTION A1 A0
PORT A 0 0
PORT B 0 1
PORT C 1 0
CONTROL 1 1
The RD and WR input pins determine the direction of data flow over the chips 8 bit
bidirectional data bus.
The RESET input of 8255A is connected to the system reset line so that, when the system
is reset all the port lines are initialized as input lines. This is done to prevent destruction
of circuitry connected to port lines.
A1 A0 RD WR CS INPUT OPERATION
0 0 0 1 0 PORT A->DATA BUS
0 1 0 1 0 PORT B->DATA BUS
1 0 0 1 0 PORT C->DATA BUS
2. OUTPUT OPERATION
A1 A0 RD WR CS INPUT OPERATION
0 0 1 0 0 DATA BUS->PORT A
0 1 1 0 0 DATA BUS->PORT B
1 0 1 0 0 DATA BUS->PORT C
1 1 1 0 0 DATA BUS ->CONTROL
3. DISABLE FUNCTION
A1 A0 RD WR CS INPUT OPERATION
X X X X 1 DATA BUS TRISTATE
1 1 0 1 0 ILLEGAL CONDITION
X X 1 1 0 DATA BUS TRISTATE
1. MODE 0
When programmed for MODE 0, the PPI offers three simple I/O ports with no
handshaking signals.
This mode is appropriate for I/O devices that do not need special synchronizing signals to
exchange data with the processor.
When used as O/Ps, the PORT c lines can be individually set or reset by sending a special
control word to control register address.
Two halves of PORT C are independent so one half can be initialized as input and the
other half as output.
2. MODE 1
When programmed for MODE 1, the PPI offers PORT A or PORT B for a handshake
input/output operation.
Pins PC3,PC4 and PC5 function as handshake signal for PORT A (input).
Pins PC6 and PC7 are available for use as input/output lines for PORT A
PORT C pins PC4 and PC5 are used as input/output lines for PORT A
3. MODE 2
This means that data can be outputed/inputed from same eight lines.
If PORT A is initialized in MODE 2, then pins PC3 through PC7 are used as handshake
lines for PORT A.
The other three pins PC0 through PC2 can be used for I/O port if PORT B is in MODE 0.
The same 3 pins will be used for PORT B handshake signals if PORT B is initialized in
MODE 1.
Write the 80x86 initialization routine required to program the 8255A for mode 0, with PORT
A as an output port and PORT B and C as an input ports.
SOLUTION
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 0 1 0 1 1
MOV AL,8BH
OUT 0FFH,AL
PROBLEM 2
Write an 80x86 program to input a byte from PORT B of PPI chip and output this byte to
PORT A of the same chip. Assume it is already initialized.
SOLUTION
PROBLEM 3
Write instruction to initialize 8255 to configure PORT A as simple output port, PORT B as
simple input port, PORT C upper as output and port c lower as an input port.
PROBLEM 4
Write a program to take input from the 8 switches connected to PORT B and display the
status of the switches thus red in the 8 LEDS connected to PORT A. Show how you derive the
control word.
PROBLEM 5
A device is sometime necessary to mark intervals of time for both the processor and external
devices , count external events and make the count available to the processor , and provide
external timing that can programmed from the processor . This device is called a programmable
interval timer / event counter .
The 8254 is a programmable interval timer/counter designed for use with Intel microcomputer
systems.It is a general purpose, multi-timing element that can be treated as an array of I/O ports in
the system software. The 8254 solves one of the most common problems in any microcomputer
system, the generation of accurate time delays under software control. Instead of setting up timing
loops in software, the programmer configures the 8254 to match his requirements and programs
one of the counters for the desired delay. After the desired delay, the 8254 will interrupt the CPU.
Software overhead is minimal and variable length delays can easily be accommodated.
Some of the other counter/timer functions common to microcomputers which can be implemented
with the 8254 are:
# Real time clock
#Measure time delay between events
# Even counter
# Programmable baud rate generator
# Square wave generator
# Binary rate multiplier
# Waveform generator for A/D converter
# Complex motor controller
BLOCK DIAGRAM
READ/WRITE LOGIC
The Read/Write Logic accepts inputs from the system bus and generates control signals for the
other functional blocks of the 8254. A1 and A0 select one of the three counters or the Control
Word Register to be read from/written into. A ``low'' on the RD input tells the 8254 that the CPU
is reading one of the counters. A ``low'' on the WR input tells the 8254 that the CPU is writing
either a Control Word or an initial count. Both RD and WR are qualified by CS; RD and WR are
ignored unless the 8254 has been selected by holding CS low. The WRÝ and CLK signals should
be synchronous. This is accomplished by using a CLK input signal to the 8254 counters which is
a derivative of the system clock source. Another technique is to externally synchronize the WRY
and CLK input signals. This is done by gating WRÝ with CLK.
GENERAL OPERATION
After power-up, the state of the 82C54 is
undefined. The Mode, count value, and
output of all Counters are undefined.
How each Counter operates is determined
when it is programmed. Each Counter
must be programmed before it can be
used. Unused counters need not be
programmed.
Counters are programmed by writing a Control Word and then an initial count.
The programming procedure for the 82C54 is very flexible. Only two conventions need to be remembered:
1) For each Counter, the Control Word must be written before the initial count is written.
2) The initial count must follow the count format specified in the Control Word (least significant byte only,
most significant byte only, or least significant byte and then most significant byte).
Since the Control Word Register and the three Counters have separate addresses (selected by the A1, A0
inputs), and each Control Word specifies the Counter it applies to (SC0, SC1 bits), no special instruction
sequence is required. Any programming sequence that follows the conventions above is acceptable. A new
initial count may be written to a Counter at any time without affecting the Counter's programmed Mode in
any way. Counting will be affected as described in the Mode definitions. The new count must follow the
programmed count format. If a Counter is programmed to read/write two-byte counts, the following
precaution applies: A program must not transfer control between writing the first and second byte to
another routine which also writes into that same Counter. Otherwise, the Counter will be loaded with an
incorrect count.
D0
Binary number divisor 0000‐FFFFH (D0 =0)
• Divisor = 65536 if the counter is loaded with 0 for both the low and the high bytes.
BCD divisor 0000‐9999H (D0=1)
• Divisor = 10000 if the counter is loaded with 0 for both the low and the high bytes.
D1, D2, and D3: Mode selection
Mode 0: Interrupt on terminal count
Mode 1: Programmable one‐shot
Mode 2: Rate generator
Mode 3: Square wave rate generator
Mode 4: Software triggered strobe
Mode 5: Hardware triggered strobe
We can write the value of the divisor into 8253/54 timer and read the contents of the counter
at any time.
D6 and D7 are used to select which of the three counters: counter 0 (00), counter 1 (01), and
counter 2 (10).
Example 1
Pin CS of a given 8253/54 is activated by binary address
A7‐A2 = 100101.
Find the port addresses assigned to this 8253/54.
Counter 0 Port address = 1001 01 00 = 94H
Counter 1 Port address = 1001 01 01 = 95H
Counter 2 Port address = 1001 01 10 = 96H
Control register Port address = 1001 01 11 = 97H
Find the configuration for this 8253/54 if the control register is
programmed as follows.
Example 2
Use the port addresses in Ex. 1 to program counter 2 for binary count of mode 3 (square
wave) to divide CLK2 by number C26AH and find the frequency of OUT2 if CLK2 = 1.8 MHz.
Example 3
Using the port address in Ex.1, show the programming of counter 1 to divide CLK1 by
10,000, producing the mode 3 square wave. Use the BCD option in the control byte.
DMA is used in large blocks of data transfer at a high speed to or from high speed devices, magnetic
drums, disks, tapes, etc. We use DMA controller which is interface that provides I/O transfer of data
directly to and from the memory and the I/O device. CPU initializes the DMA controller by sending a
memory address and the number of words to be transferred.
Actual transfer of data is done directly between the device and memory through DMA controller
freeing CPU for other tasks.
The 8237A Multimode Direct Memory Access (DMA) Controller is a peripheral interface circuit for
microprocessor systems. It is designed to improve system performance by allowing external devices
to directly transfer information from the system memory. Memory‐to‐memory transfer capability is
also provided. The 8237A offers a wide variety of programmable control features to enhance data
throughput and system optimization and to allow dynamic reconfiguration under program control.
A DMA controller is designed to service one or more I/O or mass storage interfaces and each
interface is connected to the controller by a set of conductors. A portion of a DMA controller for
servicing a single interface is called a channel.
Each channel will have
a) Control Register
b) Status Register
c) Address Register
d) Byte Count Register
When data are being put in or taken out from its control registers by the CPU,it is acting a s
slave.When it is in the control of the bus , it is acting as the master.
The 8237 includes Control and status register and four channels. Each channel contains a
1) mode register
2) current address register
3) base address register
4) current byte counter
5) base byte counter
6) request flag and
7) mask flag
Bit 5 of the mode register specifies whether the contents of the address register are to be
incremented(0)or decremented(1) after each data transfer , thus determining the order in which
the data is stored in the memory.
If bit 4 is 1 , then autoinitialization is enabled.When the current address and current byte count
registers are initially loaded, their contents are also put in the base address and base byte count
registers. If autoinitialization is enabled, the current registers are automatically reloaded from
the base registers whenever the count goes to zero.
Cycle Stealing
While DMA I/O takes place, CPU is also executing instructions .When DMA Controller and CPU
both access Memory, Memory Access Conflict arises. This is managed by Memory Bus controller.
It coordinates the activities of all devices requesting memory access using priority system.
Memory accesses by CPU and DMA Controller are interwoven, with the top priority given to DMA
Controller. Cycle stealing is the mode in which DMA controller take over the bus for each byte of
data to be transferred and then return control to the CPU. Since the processor originates most
memory access cycles, it is often stated that DMA steals memory cycles from the processor. CPU
is usually much faster than I/O(DMA), thus CPU uses the most of the memory cycles, DMA
Controller steals the memory cycles from CPU.For those stolen cycles, CPU remains idle.
Demand Transfer mode the device is programmed to continue making transfers until a
TC or external EOP is encountered or until DREQ goes inactive. Thus transfers may
continue until the I/O device has exhausted its data capacity. After the I/O device has had
a chance to
catch up, the DMA service is re‐established by means of a DREQ. During the time
between services when the microprocessor is allowed to operate, the intermediate
values of address and word count are stored in the 8237A Current Address and Current
4) Cascade Mode(11)
In this mode 8237’s are cascaded. This mode is used to cascade more than one
8237A together for simple system expansion. The HRQ and HLDA signals from the
additional 8237A are connected to the DREQ and DACK signals of a channel of the initial
8237A. This allows the DMA requests of the additional device to propagate through the
priority network circuitry of the preceding device. The priority chain is preserved and the
new device must wait for its turn to acknowledge requests. Since the cascade channel of
the initial 8237A is used only for prioritizing the additional device, it does not output any
address or control signals of its own. These could conflict with the outputs of the active
channel in the added device. The 8237A will respond to DREQ and DACK but all other
outputs except HRQ will be disabled. The ready input is ignored.
The INTEL 8279 is specially developed for interfacing keyboard and display devices to
8085/8086/8088 microprocessor based system. The important features of 8279 are,
Keyboard section:
The keyboard section consists of eight return lines RL0 ‐ RL7 that can be used to
form the columns of a keyboard matrix.
It has two additional input : shift and control/strobe. The keys are automatically
debounced.
The two operating modes of keyboard section are 2‐key lockout and N‐key
rollover.
In the 2‐key lockout mode, if two keys are pressed simultaneously, only the first
key is recognized.
In the N‐key rollover mode simultaneous keys are recognized and their codes are
stored in FIFO.
Display section:
The display section has eight output lines divided into two groups A0‐A3 and B0‐
B3.
The output lines can be used either as a single group of eight lines or as two
groups of four lines, in conjunction with the scan lines for a multiplexed display.
The output lines are connected to the anodes through driver transistor in case of
common cathode 7‐segment LEDs.
The cathodes are connected to scan lines through driver transistors.
The display can be blanked by BD (low) line.
The display section consists of 16 x 8 display RAM. The CPU can read from or
write into any location of the display RAM.
Scan section:
The scan section has a scan counter and four scan lines, SL0 to SL3.
In decoded scan mode, the output of scan lines will be similar to a 2‐to‐4 decoder.
In encoded scan mode, the output of scan lines will be binary count, and so an
external decoder should be used to convert the binary count to decoded output.
The scan lines are common for keyboard and display.
The scan lines are used to form the rows of a matrix keyboard and also connected
to digit drivers of a multiplexed display, to turn ON/OFF.