2022-12-05 02:02 PM
I'm using an STM32F429. I have setup a timer to capture rising edges on CH1 and a DMA to store the captured values into a circular buffer.
How can I temporarily stop the DMA from placing new values into the buffer while I'm reading values from the buffer? Can I just disable the DMA channel? Can I just clear the EN bit in the DMA_SxCR register, do the calculations and then re-enable by setting the EN bit in the DMA_SxCR register?
Or do I clear/set the CC1DE bit in the TIMx_DIER register?
2022-12-05 06:35 PM
Why not read where the dma is about to write and read anywhere else, without introducing a discontinuity?
2022-12-06 08:56 PM
Typical method is to process the buffer half at a time using the half- and full-complete interrupts. At half-complete, process the first half. At full complete, process the second half. As long as your code processes faster than values are stored, this works.
Disabling the DMA channel will work but you will need to reset NDTR to the correct value. Clearing CC1DE will also stop values being sent temporarily.