UNIT 12 · MOVING AND PROCESSING DATA
Data Transfer and Buffering
Let hardware move the data while the CPU does the thinking.
A UART at a megabaud, an ADC at half a million samples a second, an audio stream that must never pause: moving that data one interrupt at a time can eat the whole CPU. A DMA controller copies it between peripherals and memory by itself, paced by the peripheral, and interrupts only when a block is done. The new questions are about buffers: how big, how they wrap, who may touch them when, and what a data cache does to the answer.
The unit in six ideas
- 1Moving data with an interrupt per byte costs rate × cycles per interrupt; at high rates that exceeds the CPU.
- 2The transfer direction decides which address increments: a peripheral data register stays fixed, a buffer walks.
- 3The transfer size must match the peripheral register and the buffer’s element type.
- 4For a continuous stream, a DMA channel writes a circular buffer: circular mode, address wrapping, or re-arming.
- 5A continuous source loses data with one buffer, for t_proc × f_s samples per block.
- 6A DMA buffer belongs to the CPU or the device, never both; ownership passes at start and completion.
Lessons
Moving Data Without the CPU
What is that block, and what does it cost?
Transfer Sources, Destinations, and Requests
Who decides when it is allowed?
Transfer Widths, Alignment, and Address Increment
What does a DMA channel count, and what else about the buffer must match the transfer?
Circular Buffers and Producer-Consumer Flow
What changes when the writer is a DMA channel that never stops and never asks?
Double Buffering and Continuous Streams
How do you process a block while the next one is already arriving?
Buffer Ownership, Overruns, and Cache Coherency
How do you keep them in agreement, and how would you even know that data was lost?