cancel
Showing results for 
Search instead for 
Did you mean: 

Repetition Timer PWM Help

Stemcy
Associate

 

Hello, I'm wondering if there is an obvious way to generate a limited set of n pulses from an external trigger?

At the moment i'm using TIM8 in one pulse mode with repetition but my problem is that i want the White pulse train to start with the rising edge of Red while maintaining some gap between the pulses.  I can't seem to figure it out.

 

Stemcy_0-1725299151951.png

 

Thanks

 

4 REPLIES 4

Try to make a drawing, showing what do you want to achieve. 

JW

TDK
Guru

So what about the picture you showed is wrong? Do you only want the white rising edge closer to the red rising edge? If so, use combined PWM mode, set CCR1 to 1 and CCR2 to whatever you need for the duty cycle. If 50% duty cycle, set it to (CCR + 3) / 2.

Keep in mind they can never be perfectly aligned.

If you feel a post has answered your question, please click "Accept as Solution".
Stemcy
Associate

So this is what i'm trying to achieve

 

Stemcy_0-1725343842773.png

 

Thanks

 

The way how Compare thus PWM generation works in the STM32 timers is, that the "idle" value is what continues to be output also during the first portion of the timer cycle. So, to achieve what you've drawn, some trickery is needed. @TDK 's suggestion (to use Combined mode with one of the channel's CCRx set to 1 so that outputting the "idle" value is disabled) is probably the simplest way to go; at the cost of 1 (prescaled) timer cycle delay.

JW