Skip to main content
Associate II
September 16, 2024
Solved

Recommendation for stopping PWM signal

  • September 16, 2024
  • 2 replies
  • 2232 views

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

2 replies

mƎALLEm
mƎALLEmBest answer
Technical Moderator
September 16, 2024
To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Associate II
September 17, 2024

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

waclawek.jan
Super User
September 16, 2024

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

Associate II
September 17, 2024

I will look into this than you.