0% found this document useful (0 votes)
15 views

Module 3 Memory Interfacing

Uploaded by

Shreeyash Jadhav
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)
15 views

Module 3 Memory Interfacing

Uploaded by

Shreeyash Jadhav
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/ 49

I/O Interfacing of 8086

Using 8255
• Any application of Microprocessor Based system Requires the transfer of data
between external circuitry to the Microprocessor and Microprocessor to the
External circuitry. User can give information (i.e., input) to the Microprocessor
using keyboard and user can see the result or output information from the
Microprocessor with the help of display.

• Hence interfacing is used to exchange information between two different


applications/devices.
D0-D7 (Data Bus) –
These are bidirectional, tri-state data bus lines are connected to the system data bus.
They are used to transfer data and control word from microprocessor to 8255 or
receive data or status word from 8255 to the microprocessor.
PA0-PA7 (Port A) –
These are 8 Bit bidirectional I/O pins used to send data to output device and to
receive data from input device. It functions as an 8 Bit data output latch/buffer
when used in output mode and as an 8 Bit data input latch/buffer when used in
input mode.
PB0-PB7 (Port B) –
These are 8 Bit bidirectional I/O pins used to send data to output device and to
receive data from input device. It functions as an 8 Bit data output latch/buffer
when used in output mode and as an 8 Bit data input latch/buffer when used in
input mode.
PC0-PC7(Port C) –
These are 8 bit bidirectional I/O pins divided into two groups PCL (PC3-PC) and PCU
(PC7- PC4).these groups can individually transfer data in or out when programmed for
simple I/O and used as handshake signals when programmed for handshake or bidirectional
modes.
RD’ –
When this pin is low, the CPU can read data in the ports or the status word through the data
bus buffer.
WR’ –
When this pin is low, the CPU can write data on the ports or in the control register through
the data bus buffer.
CS’ –
This pin can be enabled for data transfer operation between the CPU and 8255.
RESET –
This pin is used to reset 8255.i.e control register gets cleared and all the ports are set to the
input mode.
A0-A1 –
The selection of input port and control word register is done by using
A0 and A1 pins in conjunction with RD and WR pins.
Data Bus Buffer
It is used to interface the internal data bus of 8255 to the system data bus by reading
and writing operations.
Read/write Control logic
It accepts the input from the address bus and issues commands to the individual
group blocks. also issues appropriate enabling signals to access the required
data/control words/status words.
Port A
It can be programmed in three modes Mode0, Mode1 and Mode2.
Port B
It can be programmed in modes Mode0 and Mode1.
Port C
It can be programmed for Bit Set/reset operation.
There are two main operational modes of 8255:
1. Input/output mode
2. Bit set/reset mode (BSR Mode).

I/O mode again classified into three types


a. Mode 0
b. Mode 1
c. Mode 2
It is a port c bit set/reset mode.
The individual bit of port c can be set or reset by writing control word in the
control register.
Write set of instructions to perform the following –
1) Set bit-4 of port C
2) Reset bit-4 of port C
Assume the address PA = 10H, PB = 12H, PC = 14H and Control register = 16H
There are three I/O modes of operation-
1. Mode 0 – Basic I/O
2. Mode 1 – Strobed I/O
3. Mode 2 – Bit-directional I/O
I/O modes are programed using control register.
When 8255 is reset, it will clear control word register contents and all
the ports are set to input mode.
The ports of 8255 can be programmed for other modes by sending
appropriate bit pattern to control register.
Ex. - Write a set of instructions to perform the following –
1. Initialize port A as input, port B as output, port C upper as output and port C lower as input.
2. Use Mode-0 for group A and Mode-1 for group B
The control word format required will be,

The initialization instructions are –


MOV Al, 95H
OUT CWR, AL
Mode 0 – (Simple Input / Output Mode)
In this mode, the ports can be used for simple input/output operations without
handshaking.
If both port A and B are initialized in mode 0, the two halves of port C can be either
used together as an additional 8-bit port, or they can be used as individual 4-bit
ports.
Since the two halves of port C are independent, they may be used such that one-half
is initialized as an input port while the other half is initialized as an output port.

Features -
▪ Two 8-bit ports and two 4-bit ports
▪ Any Port can be input or output
▪ Outputs are latched
▪ Input are not latched
▪ 16 different Input/Output configurations possible
Timing waveform for mode 0 input mode

Timing waveform for mode 0 output mode


Mode 1 – (Strobed I/O)
When we wish to use port A or port B for handshake (strobed) input or
output operation, we initialize that port in mode 1.
For port B in this mode (irrespective of whether is acting as an input
port or output port), PC0, PC1 and PC2 pins function as handshake
lines.

Functions –
▪ Two ports i.e., port A and B can be use as 8-bit i/o port.
▪ Each port uses three lines of port c as handshake signal and remaining
two signals can be function as i/o port.
▪ Interrupt logic is supported.
▪ Input and Output data are latched.
Mode 2 – (Strobed Bi-directional I/O)
Only group A can be initialized in this mode.
Port A can be used for bidirectional handshake data transfer. This means that
data can be input or output on the same eight lines (PA0 - PA7).
Pins PC3 - PC7 are used as handshake lines for port A.
The remaining pins of port C (PC0 - PC2) can be used as input/output lines if
group B is initialized in mode 0.
In this mode, the 8255 may be used to extend the system bus to a slave
microprocessor.
Program Statement –
Write a program to blink port C bit-2 of 8255. Assume address of
control word register of 8255 as 83H. Use Bit Set / Reset mode.

Control word to make bit-2 HIGH

Control word to make bit-2 LOW


DMA Channels
• 8257 has 4 independent DMA channels (CH0 to CH3), hence four I/O
devices can request for DMA simultaneously.
• Each channel consists of two 16-bit registers (i) Address register (ii) Count
Register.
• Address register holds the starting address of the memory block to be
accessed by I/O device.
• Count register holds the number of bytes to be transferred during DMA
action.
The low order 14-bits of count register specify the number of bytes;
therefore, each channel can support data transfer of 2^14=16KB during
DMA process.
The high order 2-bits of count register specify the mode of operation
(read, write or verify)
DMA Cycles:
DMA READ : In this cycle, data is transferred from memory to I/O device.
DMA Write : In this cycle, data is transferred from I/O device to memory.
DMA Verify :
In this cycle, data is not transferred between memory and I/O.
It is used by the peripheral device to verify the data that has been recently transferred.
To avoid overwriting registers of channel 3, update flag in the status register can be
monitored by the CPU.
Data Bus Buffer
This 8-bit Bidirectional buffer is used to interface the 8257 to the system Data
Bus.
It allows the transfer of data and information between 8257 and microprocessor.
In master mode, it is used to output the higher order (A8-A15) of memory
address.
In slave mode, it is used to transfer the data between 8257 and microprocessor.
Read/Write Control Logic
8257 operates in two basic modes, master mode and slave mode.
In the slave mode, read/write logic accepts the read or write signal.
In the master mode, read/write logic generates the signals for DMA write cycle or
and for DMA read cycle.
Priority Resolver
This logic block determines the priorities of the channels when more than one I/O
device request for DMA.
By default, the priority resolver work in fixed priority mode.
In this mode the CH0 has the highest priority while the CH3 has lowest.
In rotating priority, the priority of the channels has a circular sequence.
The channel which has being just serviced move to the lowest priority and channel
next to it move to the highest priority, hence each channel achieves the highest
priority in rotation.
Fixed Priority Mode :
In the fixed priority, channel 0 has the highest priority and channel 3 has the lowest
priority.

In the fixed priority, after recognition of any one channel for service, the other channels are
prevented from interfering with that service until it is completed.
If bit 4 of mode set register is logic 0, Operating Modes of 8257 operates in fixed priority
mode.
Rotating Priority Mode :
In rotating priority mode, the priority of the channels has a circular sequence.
In this, channel being serviced gets the lowest priority and the channel next to it gets the
highest priority.

Thus, with rotating priority in a single chip DMA system, any device requesting service is
guaranteed to be recognized after not more than three higher priority services have
occurred.
This prevents any one channel from monopolizing the system.
The rotating priority mode can be set by writing logic ‘1’ in the bit 4 of the mode set
register
Control Logic
In the master mode, Control logic controls the sequence of operation during DMA
cycles (DMA read, DMA write & DMA verify).
It also generates required control signals and memory address to be accessed.
It increments 16-bit address register and decrement count register of corresponding
channel during DMA action.
It is disabled in slave mode.
Mode Set Register
Extended Write Mode :
Microcomputer systems allow use of various types of memory and I/O devices with
different access time.

If a device can not be accessed within a specific amount of time it returns a “not ready”
indication to the 8257 that causes the 8257 to insert one or more wait states in its internal
sequencing.

The extended write option provides alternative timing for the I/O and memory write
signals which allows the devices to return an early READY and prevents the unnecessary
occurrence of wait states in the Operating Modes of 8257.

It does this by activating MEMW and IOW signals earlier in the DMA cycle, giving more
setup time.
TC STOP Mode :
If the TC stop bit is set, a channel is disabled (i.e. its enable bit is reset) after the terminal
count (TC) output goes high, thus automatically preventing further DMA operation on
that channel.

To enable DMA operation on the channel it is necessary to set enable bit of the
corresponding channel in the mode set register.

If the TC STOP bit is not set, the occurrence of the TC output has no effect on the
channel enable bits.
Auto Load Mode :
Auto load Mode when enabled, permits block chaining operations, without immediate software
intervention between blocks.

In this mode, channel 2 parameters (DMA starting address, terminal count and DMA transfer mode)
are initialized as usual for the first data block.

These parameters are automatically duplicated in the channel 3 registers when channel 2 is initialized.

After the first block of DMA cycles is executed by channel 2 (i.e., after the TC output goes high), the
parameters stored in the channel 3 registers are transferred to channel 2 during an ‘update’ cycle and
next block of DMA cycle is executed.

This repeat block operations can be used in applications such as CRT refreshing.
1. It is a 4-channel Direct Memory Access (DMAC) interface IC which allows data transfer between memory and
up to 4 I/O devices, bypassing CPU.
2. A maximum of 16 KB of data (= 214) can be transferred by this IC sequentially at a time. When a DMA request
comes from a peripheral, the DMAC 8257, via its HRQ (Hold Request) pin, requests the CPU on its HOLD pin.
CPU then acknowledges this request via its HLDA pin which goes to HLDA pin of 8257. After this, DMAC
generates the required MEMR, MEMW, I/OR, I/OW signals.
3. Initialization of the DMAC is done under program control for each channel. The parameters which need to be
initialized for each channel are starting address, number of bytes of data to be transferred, mode of operation, etc.
4. DMAC can be operated in three modes: (a) DMA Read (reading from memory, writing into peripheral), (b)
DMA Write (writing into memory, reading from peripheral), (c) DMA verify.
5. Priority for each of the 4 channels can be set in (a) fixed priority, (b) rotating priority.
6. A Terminal Count Register exists for each of 4 channels. The number of bytes of data to be transferred is
stored in the D13–D0 positions of the 16-bit Terminal Count Register. On completion of data transfer, the
Terminal Count (TC) pin goes high.
7. When the CPU is in control of its buses (address bus, data bus and control bus), it acts as master and DMA
controller acts as the slave. When DMA controller takes control of the buses, it becomes the master and CPU
becomes the slave.
The 8259 can be programmed
through a sequence of simple I/O
operations It accepts two types of
command words.

They are :
(a) Initialization Command Word
(ICW)
(b) Operational Command Word
(OCW)

You might also like