| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| en:multiasm:cs:chapter_3_13 [2025/12/12 11:39] – ktokarz | en:multiasm:cs:chapter_3_13 [2026/01/10 20:22] (current) – pczekalski |
|---|
| ====== DMA ====== | ====== DMA ====== |
| Direct memory access (DMA) is the mechanism for fast data transfer between peripherals and memory. In some implementations, it is also possible to transfer data between two peripherals or from memory to memory. DMA operates without the activity of the processor. No software is executed during the DMA transfer. It must be supported by a processor and peripheral hardware, and there must be a DMA controller present in the system. The controller plays the main role in transferring the data. | Direct memory access (DMA) is the mechanism for fast data transfer between peripherals and memory. In some implementations, it is also possible to transfer data between two peripherals or from memory to memory. DMA operates without processor activity. No software is executed during the DMA transfer. It must be supported by a processor and peripheral hardware, and a DMA controller must be present in the system. The controller plays a key role in transferring data. |
| |
| The DMA controller is a specialised unit which can control the data transfer process. It implements several channels, each containing the address register, which is used to address the memory location and a counter to specify how many cycles should be performed. The address register and counter must be programmed by the processor. It is usually done in the system startup procedure. The system with an inactive DMA controller is presented in Fig.{{ref>DMAinactive}}. | The DMA controller is a specialised unit that controls the data transfer process. It implements several channels, each containing an address register, which is used to address the memory location and a counter specifying how many cycles should be performed. The address and counter registers have corresponding temporal address and counter registers that are updated after every transfer. The address register and counter must be programmed by the processor. It is usually done in the system startup procedure. The system with an inactive DMA controller is presented in Fig.{{ref>DMAinactive}}. |
| |
| <figure DMAinactive> | <figure DMAinactive> |
| </figure> | </figure> |
| |
| The process of data transfer is done in some steps. Let us consider the situation when a peripheral has some data to be transferred. | The process of data transfer is done in some steps. Let us consider the situation in which a peripheral has data to be transferred. |
| * peripheral signals the request to transfer data (DREQ). | * peripheral signals the request to transfer data (DREQ). |
| * DMA controller forwards the request to the processor (HOLD). | * DMA controller forwards the request to the processor (HOLD). |
| * If the counter reaches zero, data transfer stops. | * If the counter reaches zero, data transfer stops. |
| |
| Everything is done without any action of the processor. No program is fetched and executed. Because everything is done by hardware, the transfer can be done in one memory access cycle, so much faster than by the processor. Data transfer by the processor is significantly slower because it requires at least four instructions of program execution and two data transfers: one from the peripheral and another to the memory for one cycle. The system with an active DMA controller is presented in Fig.{{ref>DMAactive}}. | Everything is done without any action on the processor's part. No program is fetched and executed. Because everything is handled by hardware, the transfer can be completed in one memory access cycle, much faster than by the processor. Data transfer by the processor is significantly slower because it requires at least four program-execution instructions and two data transfers: one from the peripheral and another to memory, per cycle. The system with an active DMA controller is presented in Fig.{{ref>DMAactive}}. |
| |
| <figure DMAactive> | <figure DMAactive> |
| * Transparent - DMA works when the CPU is executing instructions | * Transparent - DMA works when the CPU is executing instructions |
| |
| DMA controllers are implemented in personal computers, but also in advanced microcontrollers and systems on a chip, to support data transfers between internal memory and internal peripherals. | DMA controllers are implemented in personal computers, as well as in advanced microcontrollers and systems-on-a-chip, to support data transfers between internal memory and internal peripherals. |
| |