cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 PWM to stop after n pluses

Wleon.1
Associate II

Is there a way to stop STM32 PWM after 10 pluses ?

I know one solution is using the system time and issue a stop via the code, however my issue is the stm CPU might be very busy to handle the stop signal.

19 REPLIES 19

0693W000001rRu1QAE.pngHi I dont have the option to set to DMA1 stream 2:

with only setting UDE I no interrupt/event is happening, the pluses stay the same

Hi I have change to using DMA1 stream 6, but still face the same issue where the DMA seems pretty "random".

after hours of debug I found out that the DMA starts at the last element instead of the 1st one:

arr = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8}

DMA sequence: 2 3 4 5 6 7 8 1

what is this happening ?

It depends on the very details of how your program is written, but if you still use Cube, maybe you are confused by the extra Update generated by the Cube init code setting TIM_EGR.UG.

JW

Is there a way to check the current DMA count and address ?

Observe the DMA NDTR register.

JW

Hi thanks for the reply, another question, in which document is it written TIM4 UDE is bound to DMA1 stream 6 ?, If I were to change to TIM2_CH3 and TIM8_CH1, what are the respective DMA stream ?

0693W000001rmBvQAI.png

JW

Thanks for the reply, I notice that when I connect a debugger (using the "Build and debug" option, and it is giving a FIFO error (LISR->FWIF1 is set) ) the DMA seems to have a offset, but when I use the "Build and run" option everything seems fine, is this behavior expected ? Thanks in advance