Setting up double-buffered DMA

As we saw earlier, using DMA can be very beneficial for reducing CPU usage (versus interrupts). However, one of the features that wasn't covered in the last example was continuously populating a queue (the driver required block-based calls to be made before data could be received). The driver in this example will transfer data into the stream buffer constantly, without requiring any intervention from the code calling it. That is, the driver will always be receiving bytes and pushing them into the stream buffer. 

Always receiving data presents two interesting problems for a DMA-based system:

  • How to deal with roll-over—when a buffer has been completely filled and high-speed data could still be coming in.
  • How ...

Get Hands-On RTOS with Microcontrollers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.