3 ms·
I've used these in rust to record and play audio on embedded devices. The gist is, you set up a static mut array, set the DMA peripheral to write or read to it
by the__alchemist 2y ago
I've used these in rust to record and play audio on embedded devices. The gist is, you set up a static mut array, set the DMA peripheral to write or read to it and circular mode. Use indexes to split the buffer in the middle; you do CPU IO on the half the DMA isn't accessing. Use a Half-Transfer interrupt to trigger these CPU reads/writes.
- aktau 2y agoThat sounds like double-buffering. Or did I misunderstand? Is it actually a ring-buffer? Can you give more details? What is a Half-Transfer interrupt?
- the__alchemist 2y agoYea; it's double-buffering in a ring buffer? Or maybe I don't really understand ring buffers or the terminology; thought I did from the article, since it said they were called circular buffers, and you set up the DMA in "circular" mode for this, and it's using a buffer! Half-transfer means when 1/2 of the DMA transfer size is done, an interrupt fires. So, you can use this and full-transfer interrupts to manage the sequencing.
- flohofwoe 2y agoIn a regular ringbuffer the writer just continuously pushes data to the 'head' and the reader continuously pops data from the 'tail' (and the size of the buffer is used to compensate for any 'hickups' on either side).