Search code examples
c++timerstm32stm32f4pwm

Trigger stm32 timer on PWM


I'm new to stm32 timers and have a question concerning triggering.

I would like to generate four squarewaves two of each complements of each other. That is the trivial part.

Now I would like to introduce a variable phaseshift between each of the two complementary signalgroups. (Phaseshift PWM)

Now my question, can I trigger timer 2 on the falling or rising edge of a pwm signal produced by timer 1?

Or is there another way for me to generate a phaseshift between those signals that's changeable during runtime?


Solution

  • A single advanced control timer (TIM1 or TIM8) can do all of this for you.

    See the reference manual section 17.3.11 "Complementary outputs and dead-time insertion".

    Alternatively you can chain timers, see section 13.3.15 of the same manual.