This is an old revision of the document!


DMA

Direct memory access (DMA) is the mechanism for fast data transfer between peripherals and memory. In some implementations, it is also possible to transfer data between two peripherals or from memory to memory. DMA operates without processor activity. No software is executed during the DMA transfer. A processor and peripheral hardware must support it, and a DMA controller must be present in the system. The controller plays a key role in transferring data.

The DMA controller is a specialised unit that manages data transfer. It implements several channels, each containing an address register, which is used to address the memory location and a counter specifying how many data transfer cycles should be performed. The address and counter registers have corresponding temporal address and counter registers that are updated after every transfer. The processor must program the address register and counter. It is usually done in the system startup procedure. The system with an inactive DMA controller is presented in figure 1.

System with inactive DMA controller
Figure 1: System with inactive DMA controller

The process of data transfer is done in some steps. Let us consider the situation in which a peripheral has data to be transferred.

  • The peripheral signals the request to transfer data (DREQ).
  • DMA controller forwards the request to the processor (HOLD).
  • The processor accepts the DMA cycle (HLDA) and switches off from the buses.
  • DMA controller generates the address on the address bus and sends the acknowledge signal to the peripheral (DACK).
  • Peripheral sends the data on the data bus.
  • DMA generates a write signal to store data in the memory.
  • DMA controller updates the address register and the counter.
  • If the counter reaches zero, data transfer stops.

Everything is done without any action by the processor. No program is fetched and executed. Because everything is handled by hardware, the transfer can be completed in a single memory access cycle, much faster than the processor can. Data transfer by the processor is significantly slower because it requires at least four program-execution instructions and two data transfers: one from the peripheral and another to memory, per cycle. The system with an active DMA controller is presented in figure 2. Red arrows represent active address and control signals generated by the DMA controller. The orange arrow shows the direct data transfer from the peripheral to the memory.

System performing DMA transfer
Figure 2: System performing DMA transfer

DMA transfer can be done in some modes:

  • Single - one transfer at a time.
  • Block (burst) - block of data at a time.
  • On-demand - as long as the I/O device accepts transfer.
  • Cycle stealing - one cycle DMA, one CPU.
  • Transparent - DMA works when the CPU is executing instructions.

DMA controllers are implemented in personal computers, as well as in advanced microcontrollers and systems-on-a-chip, to support data transfers between internal memory and internal peripherals.

en/multiasm/cs/chapter_3_13.1782207611.txt.gz · Last modified: by ktokarz
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0