Skip to main content
Graduate
September 16, 2024
Solved

Recommendation for stopping PWM signal

  • September 16, 2024
  • 2 replies
  • 1101 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

    This topic has been closed for replies.

    2 replies

    mƎALLEmAnswer
    Technical Moderator
    September 16, 2024
    Graduate
    September 17, 2024

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

    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

    Graduate
    September 17, 2024

    I will look into this than you.