cancel
Showing results for 
Search instead for 
Did you mean: 

Recommendation for stopping PWM signal

NoviceStm32
Associate II

Looking for a recommendation for generating a discrete number of pulses from PWM, for the example below i setup timer 1 to generate PWM and timer 2 with input capture interrupt to count the pulses, I did this with both rising and falling edge and both resulted with slight errors. I attempted to create a 3-pulse burst, but as can be seen it doesn't quite work. Any suggestions on how I can implement this better? 

 

After 3 pulses on the interrupt, I stop PWM on channel 1.

NoviceStm32_1-1726499192862.png

 

Rising Edge mode Tim2 interrupt mode, 3 full pulses generated plus a 4th partial. 

DS1Z_QuickPrint2.png

DS1Z_QuickPrint3.png

Rising Edge mode Tim2 interrupt mode, only 2 full pulses generated.

DS1Z_QuickPrint4.png

DS1Z_QuickPrint5.png

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

Look at these thread as they may help:

https://community.st.com/t5/stm32-mcus-products/generating-specified-number-of-pulses-using-pwm/td-p/161924

https://community.st.com/t5/stm32-mcus-products/how-to-generate-exact-number-of-pwm-pulses/td-p/281311

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
SofLit
ST Employee

Hello,

Look at these thread as they may help:

https://community.st.com/t5/stm32-mcus-products/generating-specified-number-of-pulses-using-pwm/td-p/161924

https://community.st.com/t5/stm32-mcus-products/how-to-generate-exact-number-of-pwm-pulses/td-p/281311

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

With TIM1 and 3 pulses, the best option is to use the Repetition counter (TIMx_RCR). Read its description in the TIM chapter in Reference Manual (RM).

JW

I will look into this than you. 

Thank you, the first link had a sample program that worked for me.