Module 3 Memory Interfacing
Module 3 Memory Interfacing
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.
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
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.
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)