The Dma Controller 8257 and 8237 .
The Dma Controller 8257 and 8237 .
The Dma Controller 8257 and 8237 .
INTRODUCTION
❏In cases where we may have faster peripheral devices, we employ the
use of the DMA controller and disconnect the microprocessor during a
DMA operation
INTRODUCTION
❏This is important, especially for systems that prioritize speed as it allows for
high-speed data transfer and frees up the microprocessor to perform other
tasks while the DMA controller handles data transfer between memory and
I/O devices
❏The DMA controller in a sense, is a second processor in the system but it is
dedicated to an I/O function.
❏A DMA controller temporarily borrows the address bus, data bus and
control bus from the microprocessor, and transfers the data bytes directly
from the IO ports to a series of memory locations or vice versa.
Direct Memory Access
❏ What is DMA?
❏ DREQ0 - DREQ3 - DMA request inputs (Four channel inputs). Used by IO devices to
request DMA transfer
❏ DACK0 - DACK3 - DMA acknowledge output signals. These are active low-output signals
from 8257 to the IO devices to inform the acceptance of a DMA request
❏ D0 - D7 - Data bus lines. Used for data transfer between the processor and the DMA
controller during the programming mode. During the DMA mode, these lines are used
as multiplexed high-order address and data lines.
❏IOR - Bidirectional IO read control signal. It is the input control signal for reading DMA
controller during the programming mode and the output control signal for reading IO
device during the DMA (memory) write cycle. Is active low
❏IOW - Bidirectional IO writes control signal. It is the input control signal for writing the
DMA controller during the programming mode and output control signal for writing the IO
device during the DMA (memory) read cycle. Is active low
❏TC - Terminal count. This output notifies the currently selected peripheral that the
present DMA cycle should be the last cycle for this data block
❏ MARK - Modulo-128 mark. This signal is sent by the DMA controller after every 128-
byte of data transfer.
❏A3 to A0 - Four bidirectional address lines. Used as input address during
programming mode to select internal registers. During DMA mode the low-order four
bits of memory address are output by 8257 on these lines.
❏A7 to A4 - Four unidirectional address lines. Used to output the memory address bits
A7 to A3 during the DMA mode.
❏AEN - Address enable output signal. It is used to enable the address latch connected
to D7 - D0 pins of 8257. It is also used to disable any buffers in the system connected to
the processor.
❏ADSTB - Address strobe output signal. It is used to latch the high-byte memory
address issued through D7 - D0 lines by 8257 during the DMA mode into an external
latch.
►MEMR - Memory read control signal. It is an output control signal issued during the
DMA read operation. Is active low
►MEMW - Memory write control signal. It is an output control signal issued during the
DMA write operation. Is active low
Functional Block Diagram of 8257
► The block diagram of 8257 is shown below and consists of the following parts:
7. Status registers.
► DMA channels – has 4 channels each with two programmable 16-bit registers.
► One register (DMA Address register) is used to program the starting address of the memory
location for DMA data transfer. Its format is as shown below:
► Another register (terminal count register is used to program a 14-bit count value and a 2-bit
code for the type of DMA transfer (Read/Write/Verify transfer). Its format is as shown
below:
❑Note that A0-A2 are all zeros when accessing the status or mode set
register.
PROGRAMMING AND READING THE 8257
REGISTERS
❑Since channel registers are 16 bits, two cycles are required to read or
write and hence there is a first/last flip-flop(F/L) which indicate whether
the upper or lower byte of register operation is taking place.
• F/L=1 →MSB
• F/L=0 → LSB
PROGRAMMING AND READING THE 8257
REGISTERS
DMA OPERATIONS
DATA TRANSFER
DATA TRANSFER
1. Input device sends a DRQ signal
2. DMA sends HRQ signal to the microprocessor
3. Microprocessor generates HOLDA connected to HOLDA of DMA
4. DMA takes over the bus. DMA generates the control signals and
address signals
5. DMA sends DACK signal to the I/O device
6. When I/O device receives DACK signal and transfers data.
7. DRQ is dropped after completion of data. This causes the HRQ signal
to be dropped as well as the HOLDA signal of the microprocessor.
SINGLE BYTE TRANSFER
❑ Single byte transfer is initiated by I/O device raising the DRQ line of one
channel of the 8257.If channel is enabled ,HRQ is output to the CPU and the
8257 waits for HOLDA signal of the microprocessor.
❑Once HOLDA is received, the DACK line is activated and the 8257 generates
the read or write command after which byte transfer occurs between the I/O
and memory
CONSECUTIVE TRANSFERS
❑If more than one channel requests service simultaneously the transfer
will occur as a burst does.
❑The ready pin in 8257 is sampled and if it is low,the 8257 enters a wait
state.When ready becomes high,the 8257 proceeds to complete the
transfer
OPERATION OF DMA CYCLE: TIMING
DIAGRAM OF 8257
OPERATION OF DMA CYCLE
❑State 1: 8257 places lower byte of memory address on A0-A7 lines and
higher bytes of memory address on D0-D7 lines. It activates AEN signal
at the falling edge and ADSTB signal at the rising edge of S1.
5/19/2023
5/19/2023
The timing control block
• The timing control block derives the internal timings
from the clock input
• In the 8237/8257 systems, the internal timings are
provided for by the 8224/8284A systems
5/19/2023
5/19/2023
8237 registers
• In the 8237 DMA controller, there is a total of 24 registers. They
include:
- 4, 16 bit base address register,
- 4, 16 bit base counter register.
- 4, 16 bit current address and
- 4, 16 bit current word count register.
- 1, temporary address register
- 1, 16 bit, temporary word count register
- 1, 8 bit status register
5/19/2023
- 1, 8 bit, command register.
- 1, 8 bit, temporary register.
- 1, 6 bit mode register
- Request register
5/19/2023
Current address register
• Each of the our channel has its own current address
register
• It hold the values of memory address, during the
Direct Memory Access Transfer.
• After each transfer, the address is automatically
incremented, or decremented, then the intermediate
values of of the address are stored in the current
address register.
5/19/2023
Current word register
• Each of the four channels have their own current word count
registers.
• It determines the number of transfers to be performs.
• After each transfer, word count is decremented. And during the
transfer, intermediate value of the word count is stored.
• At the end, when the desired number of bytes is transferred, a
Terminal Controller(TC) will be
5/19/2023
Base address, and Base word count register
• Each channel has a pair of base address and base word count register.
They store the original starting address, and the original number of
bytes to be transferred.
• Base registers are written simultaneously with their corresponding
current registers in 8 bit bytes in the program condition by the
microprocessor. Registers cannot be read by the microprocessor.
5/19/2023
Command register
• Is an 8 bit register that controls the operation of the 8237A.
• It is programmed by the microprocessor, and cleared by reset or a
master clear instruction.
5/19/2023
Mode Register
• Each of the channels has a 6-bit mode register associated with it.
When the register is being written by the microprocessor in the
program condition, bits 0 and 1 determines which channel modes
register is to be written.
5/19/2023
Request Register
• The 8237A can respond to requests for DNA services which are
initiated by the software as well as by a DREQ.
• For each channel, there’s a request bit in the 4-bit request register.
They are non maskable, and prioritized by the priority resolver.
• Each register bit is set or reset separately under software control or, it
is cleared upon generation of a TC or external EOP.
5/19/2023
5/19/2023
Mask Register
• It is a write only, 8-bit register.
• Each channel has a mask which can be set to disable the incoming
DREQ.
• The mask in each channel is set when its associated channel produces
an EOP if the channel is not programmed for auto-initialization.
• The entire register can also be set by a rest. This disables all DMA
requests until clear mask register instruction allows them to occue.
5/19/2023
5/19/2023
• It is an 8-bit read only register.
• It indicates which of the channels have reached terminal count and
which of the channels have pending DMA requests.
• Bits 0 – 3 are set every time TC is reached by that channel, or an
external EOP is applied.
• These bits are cleared upon reset, and each status read.
• Bits 4-7 are set whenever their corresponding channel is requesting
for the service.
5/19/2023
5/19/2023
Temporary Register
• The temporary register is used to hold data during the memory to
memory transfers.
• After the completion of the transfers, the last word moved can be
read by the microprocessor in the program condition.
• It always contains the last byte transferred in the previous memory-
memory operation, unless cleared by the reset.
5/19/2023
DMA CYCLES
● The 8237 is designed to operate in two major cycles. These are called Idle and Active
cycles. Each
● device cycle is made up of a number of states. The 8237A can assume seven separate
states, each composed of one full clock period.
● State I (SI) is the inactive state. It is entered when the 8237A has no valid DMA requests
pending. While in SI, the DMA controller is inactive but being programmed by the
processor.
● State S0 (S0) is the first state of a DMA service. The 8237A has requested a hold but the
processor has not yet returned an acknowledge
❏ If more time is needed to complete a transfer than is available with normal timing,
wait states (SW) can be inserted between S2 or S3 and S4 by the use of the Ready line
on the 8237.
❏ The first four states (S11, S12, S13, S14) are used for the read from-memory half and
the last four states (S21, S22, S23, S24) for the write-to-memory half of the transfer.
1.IDLE CYCLE
When no channel is requesting service, the 8237 will enter the Idle cycle and
perform ‘‘SI’’ states. In this cycle the 8237 will sample the DREQ lines every clock
cycle to determine if any channel is requesting a DMA service. The device will also
sample CS, looking for an attempt by the microprocessor to write or read the
internal registers of the 8237.
When CS is low and HLDA is low, the 8237 enters the Program Condition.
2.ACTIVE CYCLE
When the 8237A is in the Idle cycle and a non-masked channel requests a DMA service,
the device will output an HRQ to the microprocessor and enter the Active cycle. In this
cycle that the DMA service will take place, in one of four modes:
• Once the DMA controller is granted access to the system bus by the CPU, it transfers all
bytes of data in the data block before releasing control of the system buses back to the
CPU, but renders the CPU inactive for relatively long periods of time.
• Data transfer is activated by DREQ to continue making transfer during the service until a
TC or an external EOP is encountered.
• In this multiple channels are used, we can further cascade more number of DMACs.
• The 8237 transfer data from source memory location to destination memory
location.
2. Priority mode- fixed priority fixes the channel in priority order based upon
descending value of their numbers.
3.Rotating priority –the last channel to get service becomes the lowest priority channel
with the others rotating accordingly.
4.Normal Mode- is the default mode of 8237. Read( IOR and MEMR) pulses are activated
during S3 and S4 and write pulse is activated during S4
4. Extended write Mode- in this mode write (IOW and MEMR) and read (IOW and
MEMR) pulses are activated during S3 and S4. The minimum length of DMA cycle is S3.
5. Compressed Timing- the 8237A can compress the transfer time to two clock cycles.
State S3 is used to extend the access time of the read pulse. By removing state S3, the
read pulse width is made equal to the write pulse width and a transfer consists only of
state S2 to change the address and state S4 to perform the read/write.
76
INTERFACING OF DMA CONTROLLER
REFERENCES
1. Mathur Sunil. (2011). Microprocessor 8086 : Architecture, Programming and
Interfacing. PHI Learning Pvt. Ltd.
2. Microprocessor - 8257 DMA Controller. (2023). Tutorialspoint.com.
https://www.tutorialspoint.com/microprocessor/microprocessor_8257_dma_
controller.htm