Creating a basic DMA-based driver
In the prior chapter, we saw that the interrupt-based driver is considerably better than the polled approach, in terms of CPU utilization. But what about applications with a high data-rate that require millions of transfers per second? The next step in improved efficiency can be obtained by having the CPU involved as little as possible, and by pushing the work for transferring data onto specialized hardware in the MCU, namely, the DMA controller.
The example-program presented in this section can be found at Src/mainUartDMABuff.c. In presenting it, we’ll show how to create a driver that is buffer-based and interrupt-driven. The example-program is the same as the prior example-program, in the previous chapter, except we’ll be using the MCU’s DMA hardware. As in the prior example-program, bytes are received by USART2 and written to a buffer in memory. However, instead of using the CPU to write the received bytes to the buffer...