Professional Documents
Culture Documents
Lecture 9 - Direct Memory Access
Lecture 9 - Direct Memory Access
Lecture 9 - Direct Memory Access
1 2
3 4
DMA Request & Acknowledgement
8086 Pins (Refresh)
MAXIMUM MINIMUM Two signals are used to request/acknowledge for DMA
MODE MODE
transfer in microprocessor-based system :
GND 1 40 Vcc
AD14 AD15 HOLD is an input to the µp that requests a DMA action.
AD13 A16,S3 The HOLD signal is a bus request signal which asks the µp to release control
AD12 A17,S4 of the buses after the current bus cycle.
AD11 A18,S5
HLDA is an output from the µp granting the DMA action.
AD10 A19,S6
AD9 /BHE,S7
The HLDA signal is a bus grant signal which indicates that the µp has indeed
released control of its buses by placing the buses at their high-impedance
AD8 MN,/MX
states.
AD7 /RD
AD6
8086
/RQ,/GT0 HOLD
The µp responds by suspending the execution of the program
AD5 /RQ,/GT1 HLDA
AD4 /LOCK /WR
and by placing its address, data and control bus in high-
AD3 /S2 /IO,M impedance states.
AD2 /S1 DT/R
AD1 /S0 /DEN A DMA controller temporarily borrows the address bus, data
AD0 QS0 ALE bus, and control bus from the µp and transfers the data bytes
NMI
INTR
QS1
/TEST
/INTA
directly between an I/O port and a series of memory locations.
CLK
GND 20 21
READY
RESET
The HOLD input has a higher priority than the INTR or NMI
interrupt inputs.
5 6
7 8
DMA Controller
Memory
A DMA controller interfaces with several peripherals that may request DMA.
Data 6. Memory The controller…
places on data
decides the priority of simultaneous DMA requests
bus
communicates with the peripheral and the CPU, and
provides memory addresses for data transfer
7.Interface latches data The DMAC takes control of the address, data, and control buses from the
CPU
CPU.
Interface
HOLD I/O It coordinates the interaction between the memory and I/O device.
HLDA Similar to the PPI and PIT ICs, the DMAC is a programmable device
Control ultimately controlled by the CPU.
1. Interface is
2. HRQ =1 Bus ready to receive DMA controller commonly used with 8088 is the 8237 programmable
request is made data, DMA device.
request is made
3. Bus grant is DMA – DREQ high The 8237 is in fact a special-purpose microprocessor. Normally it appears as part of
returned the system controller chip-sets.
Interface
4. DACK=1 DMA The 8237 is a 4-channel device. Each channel is dedicated to a specific peripheral
8. Bus request Address device places device and capable of addressing 64 K bytes section of memory.
dropped and address on the
9. Bus grant is
control returned to 5. DMA request is address bus
dropped by the acknowledged
CPU 9 10
CPU
Problem with using DMA What DMA needs to know about the
There is only one set of buses (one set of each bus: block to be transfer?
data bus, address bus, control bus) in a given
computer and no bus can serve two masters at the Beginning Address of the block (address of
same time. first byte of data)
The buses can be used either by the main CPU 80x86
or the 8237 DMA. The number of bytes (Count) it needs to
transfer.
Since the 80x86 has primary control over the buses, it
must give permission to DMA to use them.
11 12
8237A DMA Pin Layout & Block Diagram 8237 DMA Controller -1
40-pin chip.
Connect Four channels for transferring data,
to µp
Each must be used for one device. For example, one is
used for the floppy disk, one for the hard disk...
Only one device can use the DMA to transfer data at a
given time.
With every channel there are 2 associated signals,
DREQ (DMA request) and DACK (DMA acknowledge).
17 18
DMA Programming
Initialization
Address of the first byte of the block of data that must be Accessing
transferred - Base Address.
DMAC’s
Number of bytes to be transferred - Word Count.
Word
After initialization, each channel can be enabled and Count
controlled with the use of a control word.
and
There are many modes of operation and these Address
various modes and options must be programmed
Registers
into the 8237's internal registers.
To access the 8237 registers, the 8237 provides:
4 address pins, A0 - A3,
CS pin. From the datasheet 8237 pg 10
23 24
Answer Answer – Special Notes
The port address for the channel 2 memory address register and
count register are 94H and 95H, respectively. (Refer to slide 23)
The initialization will look as follows: The contents of the memory address and count registers
can be read in the same manner (low byte first, then
MOV AX, 3400H ;load lower 4 digits of start address high byte) to monitor these registers at any time.
OUT 94H, AL ;send out the low byte of the address
MOV AL, AH
From looking at the above program one might ask, since
the system address bus is 20 bits and the memory
OUT 94H, AL ;send out the high byte of the address address is 53400H, why does this program use 16-bit
MOV AX, 2048 ;load block size into AX addresses? This is a limitation of the 8237 DMA.
OUT 95H, AL ;send out the low byte of the count The 8237, not only is the register holding the address of the block
MOV AL, AH 16 bits, but in addition there are only 16 address pins that carry
OUT 95H, AL ;send out the high byte of the count the addresses.
IBM PC solves this problem by using external 4 bits register to
hold the upper bits of address in 1M memory range.
Wake Up! Don’t you notice any wrong in the answer above ?!
Read for more from the book “The 80x86 IBM PC” by Muhammad Ali Mazidi
25 26
QUIZ Answer
When a peripheral device wants to perform a DMA operation,
it makes a request for service at one of the DRQ inputs of the
Are signal lines /MEMR and /MEMW of the 82C37A.
82C37A used in the microprocessor interface? In response to this DMA request, the DMA controller (82C37A)
switches its hold request (HRQ) output to logic 1.
NO
This signal is applied to the HOLD input of the 8088/8086.
In response to this input, the µP puts the bus signals into the
Summarize the 82C37A’s DMA high-impedance state and signals this fact to the DMA
request/acknowledgement handshake sequence. controller by switching the hold acknowledge (HLDA) output
to logic 1.
This output is applied to HLDA input of the 82C37A and
signals that the system bus is now available for use by the
DMA controller.
27 28