5.5.8 · D1Embedded Systems & Real-Time Software

Foundations — DMA — memory-to-memory, peripheral-to-memory without CPU

1,945 words9 min readBack to topic

This page assumes nothing. Before you can understand the parent note DMA, you need a small pile of words to be crisp in your head. We build each one from a picture, in an order where every word only uses words already defined.


0. The stage everything lives on: memory as a row of boxes

Before "source", "destination", or "address" mean anything, you need to see memory.

Figure — DMA — memory-to-memory, peripheral-to-memory without CPU

Look at the figure: the little houses are memory boxes. The number above each house (0, 1, 2, 3 …) is its address — that's how you say which box you mean. The number inside is the data — the actual value stored.

Related vault idea: peripherals also live at box numbers — see Memory-Mapped IO.


1. Byte, word, and item width

Figure — DMA — memory-to-memory, peripheral-to-memory without CPU

In the figure, one lavender item of width covers four boxes at once. The DMA engine can grab a whole item in a single grab if the boxes are lined up ("aligned").


2. Count and total bytes


3. Source and Destination — the from and to boxes

Figure — DMA — memory-to-memory, peripheral-to-memory without CPU

The coral arrow in the figure points from to — that arrow is the copy. Everything DMA does is repeating that one arrow times, each time nudging and along.


4. Address increments and — how the arrow walks

Here is the subtle part the parent note leans on hard, so we build it slowly.

After moving item , the addresses update:

Read this out loud: "the next source box is the current source box plus a step ."

Figure — DMA — memory-to-memory, peripheral-to-memory without CPU

The figure shows two behaviours side by side:

  • Both increment (): the arrow marches forward on both sides — this is a memory-to-memory copy, like duplicating a list.
  • Source fixed (, ): the read-box stays put while the write-boxes fill up one after another — this is peripheral-to-memory.
Recall The three directions from

alone Mem→Mem increments? ::: Both: Periph→Mem increments? ::: Source fixed , destination Mem→Periph increments? ::: Source , destination fixed


5. The bus — the single shared hallway

Figure — DMA — memory-to-memory, peripheral-to-memory without CPU

Picture a one-lane hallway between the CPU's desk and the memory shelves. When DMA is carrying a box down the hallway, the CPU has to wait to fetch its own data. This is why the parent note insists DMA is not free — it is free for the CPU's thinking, but it still occupies the hallway.


6. Clock , cycle, beat, and time

Now we can talk about speed — the last group of symbols.


7. Interrupt — the "I'm done!" tap on the shoulder


How the foundations feed the topic

Memory as boxes with addresses

Source S and Destination D

Byte word and item width w

Count N and total bytes B

Increments delta S and delta D

Time equals N times c over f

Clock f and beats

The shared bus

Bus arbitration and stalls

Interrupt done signal

Safe to read buffer

DMA transfer

Everything on the left is a word; everything flows into the single box "DMA transfer" on the right. If any left-hand box is fuzzy, the parent note will feel like magic instead of mechanism.


Equipment checklist

Cover the right side and answer out loud. If any stumps you, re-read that section above.

What is an address?
The number that names one memory box, so you can say which box you mean.
What is item width ?
How many bytes are in one item you move per grab (1, 2, or 4).
What is count , and how do you get total bytes ?
= number of items; .
What do and stand for?
Source (address you read from) and Destination (address you write to).
What does mean, and what is for a peripheral source?
"Change in"; because the peripheral data register is one fixed box.
Why is the bus a bottleneck?
It's a single shared road — only one of CPU/DMA can use it at a time.
What is , and how long is one clock tick?
Clock frequency in Hz; one tick lasts seconds.
Write the DMA transfer-time formula.
.
Why must you wait for the interrupt before reading?
DMA runs in the background; the data isn't complete until the transfer-complete interrupt fires.