cancel
Showing results for 
Search instead for 
Did you mean: 

Linked PWM signals

Repwoc
Associate II

I need to generate 3 PWM signals with the same frequency and referencing the same start point (so sort of synchronised) but with different duty cycles and delays before the pulse, like this:

Repwoc_0-1725285302189.png

I'm using a STM32G474CEU6 MCU and STM32CubeIDE.

I've spent days trying to figure out how to achieve this and so far failed.  I've had partial success with the top two (green and blue) traces by configuring a timer with centre-aligned PWM and two channels with different duty cycles.  That almost matches my requirement but it would be better if the start and end points of the blue pulse could be configured so they are not necessarily equi-distant from the start and end of the green pulse.  I've had no success with the red PWM trace.

All help much appreciated.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Use edge-aligned counter mode and Combined PWM mode, read the Combined PWM mode subchapter of TIM chapter in RM. This is good only for two channels, unless you use the Advanced timer (TIM1, TIM8, TIM20), where you can use CH5 in the combination thus freeing up the third channel for "plain" output.

(You could also use the center-aligned counter mode and Asymmetric PWM mode, but IMO it's not simpler to use).

Other option is to use the master-slave link between timers to introduce controlled delay between them.

JW

View solution in original post

2 REPLIES 2

Use edge-aligned counter mode and Combined PWM mode, read the Combined PWM mode subchapter of TIM chapter in RM. This is good only for two channels, unless you use the Advanced timer (TIM1, TIM8, TIM20), where you can use CH5 in the combination thus freeing up the third channel for "plain" output.

(You could also use the center-aligned counter mode and Asymmetric PWM mode, but IMO it's not simpler to use).

Other option is to use the master-slave link between timers to introduce controlled delay between them.

JW

Repwoc
Associate II

Thanks JW.

Eventually I got that to work, sort of:

Repwoc_4-1725309711459.png

I had to use two timers.  I couldn't get it to work with TIM1 CH5 as suggested, so the yellow and blue traces are on TIM1 and the red trace is on TIM2.

I had to fudge the timing on TIM2 because the pulse was ~ 5us delayed.  I would prefer not to do that so need to figure out how to sync the timers.

paul