cancel
Showing results for 
Search instead for 
Did you mean: 

Timer input capture with circular DMA. How do I temporarily stop the DMA and then resume?

MSipo
Senior II

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?

2 REPLIES 2
S.Ma
Principal

Why not read where the dma is about to write and read anywhere else, without introducing a discontinuity?

TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".