2024-09-02 10:51 AM
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.
Thanks
2024-09-02 01:05 PM
Try to make a drawing, showing what do you want to achieve.
JW
2024-09-02 04:51 PM
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.
2024-09-02 11:11 PM
So this is what i'm trying to achieve
Thanks
2024-09-03 12:16 AM
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