Direct Memory Access (DMA) Operation and DMA Controller
Direct Memory Access (DMA) Operation and DMA Controller
DRAM refresh
Free
Floppy disk controller
Free
8237 pins
CLK: System clock
CS: Chip select (decoder output)
RESET: Clears registers, sets mask register
READY: 0 for inserting wait states
HLDA: Signals that the p has relinquished buses
DREQ3 DREQ0: DMA request input for each channel
DB7-DB0: Data bus pins
IOR: Bidirectional pin used during programming
and during a DMA write cycle
IOW: Bidirectional pin used during programming
and during a DMA read cycle
EOP: End of process is a bidirectional signal used as input to terminate a DMA
process or as output to signal the end of the DMA transfer
A3-A0: Address pins for selecting internal registers
A7-A4: Outputs that provide part of the DMA transfer address
HRQ: DMA request output
DACK3-DACK0: DMA acknowledge for each channel.
AEN: Address enable signal
ADSTB: Address strobe
MEMR: Memory read output used in DMA read cycle
MEMW: Memory write output used in DMA write cycle
8237 registers
CAR (Current Address Register): holds the 16-bit
memory address used for the DMA transfer (one for
each channel), either incremented or decremented
during the operation
CWCR (Current Word Count Register): Programs a
channel for the number of bytes (up to 64K)
transferred during a DMA operation
BA (Base Address) and WC (Word Count): Used when
auto-initialization is selected for a channel, to reload
the CAR and CWCR when DMA is complete.
CR (Command Register): Programs the operation of
the controller
MR (Mode Register):
Programs the mode of
operation for a channel
(one for each channel).
RR (Request Register):
Used to request DMA
transfer via software
(memory-to-memory
transfers)
MR (Mask
Register):
SR (Status
Register): Shows
the status of
each DMA
channel
8237 Software
commands
Initiating a DMA
Transaction
Save the current interrupt status and disable
interrupts
Disable the channel that will be used for the
transaction
Reset the flip-flop
Set the Mode Register
Set the Page Register
Set the Offset Register
Set the Block Size Register
Enable the channel that is used for the transaction
Restore the interrupt status
Example
Design the 8237 decoding circuit and
the 8237 address line connections so
that the 8237 is in the address range
70h-7Fh
Write a program that starts a block
memory-to-memory DMA transfer
from memory locations 10000H13FFFH to 140000H-17FFFH using
channel 0 as source and channel 1 as
destination.
MOV
SHL
ADD
OUT
MOV
OUT
MOV
DEC
OUT
MOV
OUT
;PROGRAM MODE
Interrupt processing
Peripheral module to perform DMA.
Bus arbitrator.
There can only be one user of the data
bus so processor must wait if DMA is
transferring data.
DMA controller tells the processor when
the DMA has completed the transfer.
Interrupt
line
Address bus
Data bus
RAM
DMA Module
External
I/O lines
(Memory DMA)
Between memory and the I/O through a
serial or parallel port.
There are 12 DMA channels for various
transfers.
Two ways of programming DMA transfers
Descriptor-based
Register-based
Descriptor-based DMA
Transfers require a set of parameters
stored within memory to initiate a DMA
sequence.
Allows the chaining together of multiple
DMA sequences.
DMA channel can be programmed to
automatically set up and start another
DMA transfer after the current sequence
completes.
Register-based DMA
Allows the processor to directly program
DMA control registers to initiate a DMA
transfer.
On completion, the control registers may
be automatically updated with their
original setup values for continuous
transfer, if needed.
DMA Registers
DMA registers fall into three categories:
Parameter registers, such as
DMAx_CONFIG and DMAx_X_COUNT
Current registers, such as
DMAx_CURR_ADDR and
DMAx_CURR_X_COUNT
Control/Status registers, such as
DMAx_IRQ_STATUS and
DMAx_PERIPHERAL_MAP
Video Interface
Video
source
Display
Unit
VideoInPo
rt
Memor
y
Decoder
DMA
VideoOutPor
t
BF533
PPI
Interface
PPI
Interface
Encoder
Implementing DMA in a
Computer
A DMA controller implements DMA in a
computer system.
It connects directly to the I/O device at one
end and to the system buses at the other
end. It also interacts with the CPU, both
via the system buses and two new direct
connections.
Internal Configuration
TRANSPARENT Mode
This requires the most time to transfer a block of
data, yet it is also the most efficient in terms of
overall system performance.
The DMA controller only transfers data when the
CPU is performing operations.
For example, the Relatively simple CPU has
several states that move or process data solely
within the CPU:
NOP1:
(No operation)
LDAC5: ACDR
JUMP3: PCDR,TR
CLAC1: AC0, Z1
Hardware Implementation of BG
Advantages of DMA
Fast memory transfer of data
CPU and DMA run concurrently under
cache mode
DMA can trigger an interrupt, which frees
the CPU from polling the channel
DMA Hardware
Peripheral
Peripheral
NET+ARM
DMA
Receive Channel
Receive Channel
Transmit Channel
Transmit Channel
RAM
RAM
DMA in Brief
10 Channels total
8 channels wired into NET+ARM modules
Ethernet, Serial, Parallel / ENI
2 Channels available for external Memory
moves
Handshaking signals muxed into GPIO lines
Can move data while ARM executes from Cache
Simple Implementation
Good for repetitive data movement
Modes of Operation
Fly-by
Data is directly transferred between
memory and the peripheral
Memory to Memory
Data is not directly transferred, but buffered
in between transfers
Data is copied from the source location into
a temporary area in the DMA channel, and
then written into the destination location.
DMA
Request
Peripheral
Add
DMA
Controller
Memory
DMA
Grant
DATA
Memory
CS*
ADDR[X:0]
DATA[31:0]
R / W*
External Device
DRQ*
Enable
Done
Direction
DATA[31:0]
Memory
DATA
ADD
Holding FIFO
DMA
Request
DMA Grant
ADD
DATA
Peripheral
Memory
CS*
ADDR[X:0]
DATA[31:0]
R / W*
External Device
DRQ*
Enable
Done
Direction
DATA[31:0]
ADDR[X:0]
CS*
Pin
A6
A2
A0
Port A Configuration
MODE
DIR
1
0
1
1
1
1
DRQ1*
DACK1*
DONE1*
1st Xfer
2nd Xfer
Last Xfer