cancel
Showing results for 
Search instead for 
Did you mean: 

Force DMA to Start/Stop at a Particular Position

Theorem25
Associate

Hi STM32 guys/gals,

The gray/white signal is for reference only, and that's the signal I'd like the generated yellow signal to achieve when starts and stops. I'm using DMA in circular mode to generate the yellow signal. However, I'm struggling to command the signal to start and stop exactly in the middle, between peak to peak. Forcing either the timer interrupt to stop or disable the DMA will make it stop anywhere between peak-to-peak but not exactly in the middle all the time. Should DMA in normal mode better for this application?  

Stopped/started at bottom:

IMG_0018.jpg

 

Stopped/started slightly above bottom:

IMG_0020.jpg

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Theorem25
Associate

Hi Mbrossett,

Thanks for the reply. I temporary solved the problem by disabling the DMA at the end of the wave generation function. Then re-load the DMA counter with the new value to start the DMA counter again and that does the trick.

View solution in original post

2 REPLIES 2
mbrossett
Associate III

By “middle” I am going to assume you mean the zero crossing…

If not already, the sine wave lookup table should start at value 0. Then you can use a global flag to notify the DMA_XferCpltCallback() to stop the DMA at the next interrupt. This will ensure it always starts and stops at zero. Of course this also means the output will (almost) never stop immediately as it waits until the next zero crossing. 

Theorem25
Associate

Hi Mbrossett,

Thanks for the reply. I temporary solved the problem by disabling the DMA at the end of the wave generation function. Then re-load the DMA counter with the new value to start the DMA counter again and that does the trick.