Embedded systems spend a surprising amount of time moving data.
A microcontroller may repeatedly copy data:
- from an ADC into RAM,
- from RAM into a UART,
- from SPI into a sensor buffer,
- from memory into a display,
- from Ethernet into a packet buffer.
If the CPU performs every read and write itself, it wastes valuable processing cycles.
Direct Memory Access solves this problem.
A DMA controller is dedicated hardware that moves data:
- between memory locations,
- from peripherals to memory,
- from memory to peripherals
with little or no continuous CPU involvement.
The CPU normally configures the transfer once.
The DMA controller then performs the data movement independently and can notify the CPU when the transfer is complete.
This can improve:
- throughput,
- responsiveness,
- real-time behavior,
- power efficiency.
Fundamentals and Technology Overview
What Is Direct Memory Access?
DMA stands for:
Direct Memory Access.
It allows a hardware subsystem to access system memory independently of the CPU.
Microchip describes DMA as a hardware mechanism that lets high-data-throughput peripherals access data memory directly, reducing CPU-intensive management.
Arm similarly describes its CoreLink DMA architecture as a way to offload memory-movement tasks from the CPU to improve system performance and energy efficiency.
CPU-Driven Data Transfer
Consider copying 1,000 ADC samples into RAM without DMA.
The CPU might need to:
- wait for ADC completion,
- read ADC data register,
- write value into memory,
- increment pointer,
- repeat.
This consumes many CPU cycles.
The processor may also need to service:
- 1,000 interrupts.
DMA-Based Data Transfer
With DMA:
- CPU configures source address,
- CPU configures destination address,
- CPU configures transfer length,
- DMA starts,
- DMA moves the samples,
- CPU receives one completion interrupt.
During the transfer, the CPU can:
- execute control algorithms,
- process communication,
- sleep.
Basic DMA Architecture
A DMA controller typically connects to the system bus as a bus master.
It can directly access:
- SRAM,
- peripheral registers,
- sometimes external memory.
The architecture usually includes:
- channels,
- source address registers,
- destination address registers,
- counters,
- trigger selection,
- status flags.
Source and Destination
Every DMA transfer needs:
Source
Where data comes from.
Destination
Where data goes.
Examples include:
ADC → SRAM
SRAM → UART
SRAM → SRAM
Main DMA Transfer Types
Modern DMA controllers commonly support several transfer directions.
Peripheral to Memory
Example:
ADC → RAM
Used for:
- sensor acquisition,
- audio capture.
Memory to Peripheral
Example:
RAM → SPI
Used for:
- display output,
- communication transmit.
Memory to Memory
Example:
Buffer A → Buffer B
Used for:
- copying,
- rearranging data.
Peripheral to Peripheral
Some architectures support this directly or indirectly.
DMA Channels
A DMA controller usually contains multiple channels.
Each channel can manage an independent transfer.
For example:
Channel 0
ADC → buffer.
Channel 1
UART RX → buffer.
Channel 2
SPI TX ← buffer.
Microchip's dsPIC33A DMA controller includes multiple independent channels and allows selectable peripheral triggers.
DMA Triggers
DMA transfers may start because of:
- software request,
- timer event,
- ADC completion,
- UART receive,
- SPI request,
- peripheral interrupt source.
The trigger determines when data moves.
Peripheral-Triggered DMA
This is one of the most useful modes.
For example:
- ADC completes conversion,
- ADC generates DMA request,
- DMA reads result register,
- DMA stores value in RAM.
The CPU does not need to intervene for every sample.
Why DMA Improves CPU Utilization
Without DMA, the CPU spends time on repetitive data movement.
With DMA, CPU time is available for:
- algorithms,
- control loops,
- decision making.
This is particularly important in systems with limited processor performance.
DMA and System Responsiveness
When the CPU is not occupied copying data, it can respond faster to:
- safety interrupts,
- motor-control events,
- network traffic.
Microchip notes that DMA improves both:
- latency,
- throughput
because the CPU can continue with other tasks.
DMA and Power Consumption
DMA can also reduce energy consumption.
If the CPU does not need to wake for each transfer, it can:
- idle,
- enter low-power modes.
Microchip explicitly notes that DMA-based data movement can support lower-power operation.
Applications and Practical Examples
Example: ADC Sampling
Suppose an ADC samples at:
- 100 kHz.
Without DMA, the CPU may receive:
- 100,000 interrupts per second.
That creates significant overhead.
With DMA, 1,000 samples can be collected into a buffer.
The CPU may need only:
- 100 interrupts per second
if one interrupt occurs per full buffer.
Example: UART Receive
Without DMA:
- one interrupt per byte.
At high baud rates this can be inefficient.
With DMA:
- UART RX register feeds RAM automatically.
The CPU processes data only when:
- buffer is full,
- packet boundary is detected.
Example: SPI Sensor
A high-speed SPI sensor may generate large data streams.
DMA can move:
- SPI receive data → RAM
while the CPU processes the previous block.
This creates a pipeline.
Example: Ethernet
Ethernet controllers frequently use DMA descriptors to move:
- packets,
- frame buffers.
Without DMA, CPU overhead would be much higher.
Example: Audio Streaming
Audio systems need continuous sample movement.
DMA can maintain:
- ADC → audio buffer,
- audio buffer → DAC.
This prevents the CPU from manually moving every sample.
Example: Camera Capture
Image sensors produce very large data streams.
DMA is essential for moving pixels into:
- frame buffers,
- processing pipelines.
DMA in Motor Control
DMA can support motor control by moving:
- ADC samples,
- encoder values,
- PWM update data.
This lets the control CPU focus on:
- FOC,
- position control,
- safety logic.
Circular DMA
Circular mode automatically restarts the transfer when the end of a buffer is reached.
This is useful for:
- continuous sampling,
- audio,
- sensor streams.
For example:
ADC → circular buffer → ADC → circular buffer
without CPU reconfiguration after each block.
Double Buffering
Double buffering uses two buffers.
Buffer A
DMA fills.
Buffer B
CPU processes.
Then they swap.
This allows:
- continuous acquisition,
- continuous processing.
Ping-Pong Mode
Some DMA controllers call double buffering:
ping-pong mode.
Microchip's dsPIC33A DMA documentation explicitly includes ping-pong operation.
This is useful for high-throughput systems.
Half-Transfer Interrupt
A DMA controller can generate an interrupt when:
- half the buffer is complete.
The CPU can process the first half while DMA fills the second half.
This improves streaming performance.
Full-Transfer Interrupt
When the complete block is transferred, the DMA controller can generate:
- transfer-complete interrupt.
The CPU can then:
- process data,
- reuse buffer,
- schedule next operation.
Scatter-Gather DMA
Simple DMA uses one source, destination, and length.
Scatter-gather DMA uses a list of descriptors.
Each descriptor can define:
- source,
- destination,
- size,
- next descriptor.
Arm's DMA-250 supports scatter-gather style transfers.
ST's GPDMA supports linked-list transfers between peripherals and memories.
Why Scatter-Gather Matters
Suppose packet data is spread across several memory buffers.
Without scatter-gather:
- CPU combines buffers manually.
With scatter-gather:
- DMA processes descriptors automatically.
This reduces CPU overhead.
Performance, Memory, and Data Processing
Linked-List DMA
Linked-list DMA lets one transfer automatically launch the next.
This is useful for:
- complex sequences,
- streaming,
- protocol engines.
ST's 2026 GPDMA guidance emphasizes linked-list support.
Channel Chaining
Some DMA controllers can trigger another DMA channel when one channel completes.
Microchip calls this:
- channel chaining
on supported devices.
This enables complex hardware-driven workflows.
DMA Address Modes
DMA controllers may support:
- fixed address,
- incrementing address,
- decrementing address,
- circular address.
Fixed Source Address
Example:
UART data register
The peripheral address remains constant.
Incrementing Destination Address
Example:
RAM buffer
Each received byte goes into the next memory location.
Fixed Destination Address
Example:
SPI transmit register
DMA repeatedly writes to the same peripheral register.
Incrementing Source Address
Example:
RAM transmit buffer
DMA reads sequential bytes from memory.
Transfer Width
DMA controllers may support:
- 8-bit,
- 16-bit,
- 32-bit,
- larger burst widths.
The width should match:
- peripheral,
- memory,
- bus architecture.
Burst Transfers
Instead of moving one item at a time, DMA may transfer:
- several words per bus request.
Burst transfers improve throughput.
But long bursts can increase contention with the CPU.
Bus Arbitration
DMA and CPU often share the same memory bus.
If both need SRAM simultaneously, an arbiter decides:
- who gets access first.
This is called:
bus arbitration.
DMA Is Not Free Bandwidth
This is an important design point.
The DMA engine may reduce CPU instruction overhead, but it still consumes:
- memory bandwidth,
- bus bandwidth.
A poorly configured DMA transfer can delay CPU memory access.
CPU vs DMA Bus Contention
Suppose the CPU is executing from SRAM while DMA is also streaming data through SRAM.
Both compete for the same bus.
Possible result:
- CPU stalls,
- increased latency.
Dual-Port DMA Architecture
Some MCU architectures separate DMA and CPU paths to reduce contention.
Microchip documents DMA architectures where the controller operates on a dedicated peripheral data path while still accessing SRAM.
This can improve effective throughput.
Arbitration Policies
DMA controllers may use:
- fixed priority,
- round-robin.
Microchip's dsPIC33A DMA supports both approaches.
Processing Resources and Performance Tradeoffs
Fixed Priority
High-priority DMA channels always win arbitration.
Useful for:
- time-critical data.
But low-priority channels could starve.
Round-Robin
Channels take turns.
This improves fairness.
DMA Channel Priorities
Some controllers allow per-channel priority.
Example:
High Priority
ADC data.
Medium Priority
SPI sensor.
Low Priority
UART logging.
DMA and Cache Coherency
DMA becomes more complex on processors with data cache.
The CPU may have one version of data in cache while DMA reads or writes main memory.
This can create:
- stale data,
- corruption.
DMA Writing to Memory
If DMA writes new data into RAM but the CPU still has an old cached copy, the CPU may not see the new data.
Software may need to:
- invalidate cache.
DMA Reading From Memory
If the CPU modifies data in cache but has not written it back to RAM, DMA may read the old RAM contents.
Software may need to:
- clean / flush cache.
Non-Cacheable DMA Buffers
One solution is to place DMA buffers in memory regions configured as:
- non-cacheable.
This simplifies coherency but may reduce CPU performance.
Cache Maintenance
Another strategy is:
- clean cache before DMA transmit,
- invalidate cache after DMA receive.
The exact method depends on processor architecture.
Memory Alignment
DMA engines may have alignment requirements.
For best performance, buffers may need alignment to:
- word boundary,
- cache line,
- burst boundary.
Descriptor Alignment
Scatter-gather descriptors may also require specific alignment.
Ignoring these requirements can cause:
- transfer errors,
- poor performance.
DMA and Memory Protection
Modern systems may restrict which memory regions DMA can access.
This is important for:
- security,
- safety.
Arm's DMA-250 includes TrustZone-aware security support.
DMA Security Risk
A DMA engine with unrestricted access can potentially read or overwrite:
- sensitive memory,
- control structures.
Secure systems must configure DMA permissions carefully.
DMA and Real-Time Determinism
DMA can improve real-time behavior by reducing CPU interrupts.
But bus contention can introduce timing variation.
Therefore designers must evaluate:
- transfer size,
- arbitration,
- memory path.
Short DMA Bursts vs Long Bursts
Short bursts
Improve CPU responsiveness.
Long bursts
Improve data throughput.
The right balance depends on application priorities.
Practical Design Tradeoffs and Future Development
DMA and Interrupt Reduction
A major benefit is reducing interrupt rate.
Instead of:
- interrupt per byte,
- interrupt per sample,
the CPU can receive:
- interrupt per block.
This reduces:
- context switches,
- ISR overhead.
DMA and RTOS
DMA works well with RTOS systems.
A typical pattern is:
- task configures DMA,
- task blocks,
- DMA runs,
- completion interrupt wakes task.
This lets other tasks run while transfer proceeds.
DMA and Zero-Copy Design
Zero-copy systems avoid unnecessary buffer copying.
For example, an Ethernet DMA engine writes directly into the buffer that the networking stack will consume.
This reduces:
- memory bandwidth,
- CPU usage.
Peripheral-to-Peripheral Workflows
Advanced DMA engines can sometimes coordinate data movement without CPU involvement.
Example:
ADC → memory → DAC
or hardware-triggered chains.
This can enable core-independent signal pipelines.
DMA and Low-Power Sensor Nodes
In battery systems, DMA can allow the CPU to remain asleep while:
- ADC samples,
- serial data arrives.
The processor wakes only when a meaningful data block is ready.
When DMA Is Not Worth Using
DMA introduces setup overhead.
For very small transfers, CPU copying may be faster and simpler.
Example:
- copying 4 bytes once per second.
DMA configuration would add unnecessary complexity.
DMA Setup Cost
The CPU must configure:
- source,
- destination,
- count,
- trigger,
- channel.
For tiny transfers, this overhead may exceed the cost of direct copying.
DMA Debugging Complexity
DMA runs independently of CPU instruction flow.
This can make bugs harder to understand.
Typical DMA problems include:
- wrong address,
- wrong length,
- buffer overwrite,
- incorrect trigger,
- cache issue.
DMA Race Conditions
The CPU must not process a buffer while DMA is still modifying it unless the design intentionally supports concurrent access.
Double buffering helps prevent this.
Transfer Completion Flags
Software should verify:
- transfer complete,
- error state.
Do not assume a DMA transfer succeeded simply because time passed.
DMA Errors
Possible errors include:
- invalid address,
- bus error,
- alignment fault,
- transfer overflow.
Advanced controllers can signal error interrupts.
Peripheral Flow Control
Some peripherals control when DMA transfers occur.
For example:
- UART requests DMA only when receive data is available.
This prevents overrun.
DMA and FIFO
A peripheral FIFO can buffer several words.
DMA can move data in bursts between:
- FIFO,
- RAM.
This improves bus efficiency.
DMA Performance Metrics
Engineers should measure:
- throughput,
- CPU utilization,
- interrupt rate,
- bus contention,
- latency,
- power consumption.
Practical Design Tradeoffs and Future Development
CPU Load Comparison
Without DMA, the CPU may spend a large percentage of time copying data.
With DMA, CPU load can fall dramatically.
The actual improvement depends on:
- transfer size,
- frequency,
- bus architecture.
Throughput
DMA improves throughput when data transfer would otherwise become CPU limited.
Examples include:
- high-rate ADC,
- SPI,
- Ethernet,
- camera.
Latency
DMA does not always reduce the latency of a single tiny transfer.
Its biggest advantage appears with:
- repetitive,
- continuous,
- block data movement.
Power Efficiency
DMA can improve energy efficiency because:
- fewer instructions execute,
- fewer interrupts occur,
- CPU can sleep longer.
Microchip explicitly identifies power reduction as a DMA benefit.
Example: Industrial Vibration Monitoring
A vibration sensor may sample at:
- 25 kHz.
DMA stores samples into a double buffer.
While DMA fills Buffer A:
- CPU processes Buffer B.
This enables continuous:
- FFT,
- anomaly detection.
Example: Motor Drive
ADC samples current at every PWM cycle.
DMA can capture:
- current,
- voltage
into memory.
CPU spends more time on:
- control algorithm,
- diagnostics.
Example: PLC Communication Module
Ethernet and fieldbus traffic can involve continuous data movement.
DMA reduces the amount of CPU time spent copying:
- packets,
- frames.
Example: Machine Vision
Camera interfaces produce large continuous data.
DMA moves frames into memory while an accelerator processes previous frames.
DMA Selection Checklist
When evaluating a DMA controller, check:
- number of channels,
- trigger sources,
- transfer width,
- address modes,
- priorities,
- circular mode,
- double buffering,
- linked lists,
- scatter-gather,
- security,
- error handling.
Practical DMA Design Workflow
Step 1: Identify Repetitive Data Movement
Examples:
- ADC,
- UART,
- SPI.
Step 2: Measure CPU Cost Without DMA
Determine:
- interrupt rate,
- copy time.
Step 3: Choose Buffer Strategy
Options include:
- linear,
- circular,
- ping-pong.
Step 4: Configure Transfer Width and Addresses
Match the peripheral data width.
Step 5: Set Channel Priority
Protect time-critical transfers.
Step 6: Handle Cache Correctly
On cached systems, use:
- maintenance,
- non-cacheable buffers.
Step 7: Measure System Performance
Check:
- CPU load,
- throughput,
- jitter.
Common DMA Design Mistakes
Using DMA for Tiny Transfers
Setup cost may outweigh benefits.
Forgetting Cache Coherency
CPU may read stale data.
Reusing Buffer Too Early
DMA may still be active.
Ignoring Bus Contention
DMA can stall CPU memory access.
Wrong Transfer Width
Can cause corrupted data.
Too Many Completion Interrupts
Use larger blocks when latency allows.
Modern DMA Architectures
ST's GPDMA is a dual-port AHB bus master and supports:
- memory/peripheral transfers,
- linked lists.
Arm's DMA-250 supports:
- memory-to-memory,
- memory-to-peripheral,
- peripheral-to-memory,
- scatter-gather,
- security.
Microchip DMA implementations provide features such as:
- multiple channels,
- ping-pong buffering,
- chaining,
- trigger selection.
This shows how DMA controllers have evolved from simple copy engines into sophisticated data-movement subsystems.
Future Direction
DMA will become even more important as embedded devices integrate:
- faster ADCs,
- AI accelerators,
- high-speed sensors,
- industrial Ethernet.
Processors increasingly need to spend compute cycles on:
- inference,
- control,
- decision-making
instead of copying bytes.
DMA and Physical AI
Physical AI systems combine:
- sensors,
- AI compute,
- real-time control.
Large amounts of sensor data must move continuously between:
- cameras,
- ADCs,
- memory,
- accelerators.
DMA allows these systems to create efficient data pipelines while keeping CPU resources available for higher-value computation.
Conclusion
A DMA controller is one of the most important performance features in a modern embedded system.
It moves data between:
- peripherals,
- memory
without requiring the CPU to manage every transfer.
This reduces:
- CPU load,
- interrupt overhead,
- power consumption.
It can improve:
- throughput,
- responsiveness,
- real-time behavior.
Advanced DMA controllers also support:
- circular buffers,
- ping-pong operation,
- scatter-gather,
- linked lists,
- channel priorities,
- hardware triggers.
However, DMA is not free performance.
Designers must consider:
- bus contention,
- cache coherency,
- buffer ownership,
- alignment,
- transfer size.
The central engineering principle is:
let the CPU compute while dedicated hardware moves the data.
When DMA is configured correctly, an embedded processor can spend far more of its time performing useful control, signal processing, communication, and AI workloads instead of repeatedly copying data from one address to another.