In this lesson, you will learn how the Direct Memory Access (DMA) controller physically asserts control over the system bus to move data without waking the CPU.
The Problem with CPU-Driven Transfers
As we discussed in our study of architectural bottlenecks, the CPU is an "expensive" resource. If the CPU manually moves every byte from an ADC buffer to system memory, it remains trapped in a load-store loop. It cannot perform calculations, manage tasks, or respond to interrupts while it is effectively acting as a simple data pipe.
The DMA "Bus Master" Mechanism
The DMA controller is a dedicated hardware module that acts as a Bus Master. Under normal operation, the CPU owns the bus. When a peripheral (like an ADC) has data ready, it sends a request signal to the DMA controller. The controller then executes a "Bus Request" protocol:
- Request: The DMA controller signals the CPU that it needs the bus.
- Grant: The CPU finishes its current bus cycle and asserts a "Bus Grant" signal, effectively placing its own bus drivers into a high-impedance (tri-state) mode.
- Control: The DMA controller now controls the Address, Data, and Control lines.
- Transfer: The DMA controller moves the data directly between the peripheral and memory.
- Release: Once the transfer count reaches zero, the DMA controller relinquishes control, and the CPU resumes its flow.
A Conceptual View
Imagine the DMA as a clerk. Instead of the "manager" (CPU) moving every document (data byte) from the "mailroom" (ADC) to the "filing cabinet" (RAM), the manager simply gives the clerk a set of instructions:
// Pseudo-code representation of DMA Configuration
dma_channel->source_addr = &ADC_DR; // Where the data comes from
dma_channel->dest_addr = &data_buffer; // Where it's going
dma_channel->count = 1024; // How much to move
dma_channel->control = ENABLE; // Take control when ready
Once the ENABLE bit is set, the CPU is free to go back to other tasks. The DMA controller hardware manages the address incrementing and the timing of the bus cycles autonomously. It only taps the CPU on the shoulder (via an interrupt) once the entire block of data is moved, saving thousands of clock cycles of overhead.
Key Takeaway: The DMA controller functions as a bus master, temporarily putting the CPU into a suspended state to manage high-speed data movement autonomously via direct hardware signals.