Search topics...
DMAModes and Configurationfoundational

Which peripherals are commonly paired with DMA, and what configurations are typical?

0 upvotes
Practice with AISoon
Study the fundamentals first — DMA topic page

ADC: The most common DMA use case in embedded systems. DMA in circular mode transfers conversion results directly to a RAM buffer. For multi-channel scan mode, each channel's result is stored sequentially — the DMA auto-increments the memory pointer while the ADC sequences through channels. Timer-triggered ADC with DMA produces precisely timed, zero-jitter sampling with zero CPU involvement until the buffer is ready to process.

UART/USART: DMA handles both directions. For TX: memory-to-peripheral, normal mode — configure the buffer address and byte count, enable the channel, and the DMA feeds bytes to the UART data register as fast as the UART can accept them. The CPU is free immediately after starting the transfer. For RX: peripheral-to-memory, circular mode — incoming bytes fill a ring buffer continuously. Combine with the UART idle line detection interrupt to process variable-length messages: the idle interrupt tells firmware "the sender paused, process the accumulated bytes." This DMA + idle-line pattern is the gold standard for UART reception in production firmware.

SPI: DMA enables full-duplex, high-speed transfers. Configure two DMA channels — one for TX (memory to SPI_DR) and one for RX (SPI_DR to memory) — and start both simultaneously. This is essential for driving displays (pushing framebuffer data), SD card communication, and high-speed sensor interfaces where the CPU cannot keep up with the SPI clock rate. Without DMA, a 42 MHz SPI bus requires the CPU to service an interrupt every 190 ns — faster than the ISR can execute on most Cortex-M4 cores.

DAC: Timer-triggered DAC with circular DMA enables waveform generation. The DMA feeds a pre-computed waveform table (sine, triangle, arbitrary) to the DAC at each timer trigger, producing analog output signals with zero CPU involvement — the CPU just fills the table once and the hardware loops forever.

Memory-to-memory: DMA can copy between RAM regions or from flash to RAM, functioning as a hardware memcpy(). Useful for framebuffer blitting, initializing large data structures, or copying lookup tables from flash to faster RAM at startup.

Source: DMA Q&A