2024-05-29 12:44 PM
Hi,
I am new to STM32 and am using a STM32L452RET6 and need to have two PWM signals so that they can be configured via software to sometimes work in perfect sync (i.e. as if they are the same pin output) and some other times to work 180 out of sync (i.e. when one is low the other is high).
I am currently using PA0 to generate the first PWM. Which pins can I use to setup the second PWM so it works as mentioned above?
If for some reason it is preferred to use another pair of pins, can you please suggest which ones).
Thank you :smiling_face_with_smiling_eyes:
2024-05-30 08:10 AM
Hello @Ricko,
Since you're using PA0 for the first PWM, typically you're using TIM2_CH1, however, to have complementary outputs (which allow for easy configuration of out-of-phase signals), you would ideally use an advanced timer like TIM1.
if you want to use TIM1, you could use PA8 for TIM1_CH1 and PA7 for TIM1_CH1N for complementary outputs.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-05-30 09:34 AM
> when one is low the other is high
Use two channels of the same TIM, for one channel use PWM1 mode and for the other PWM2 mode.
Alternatively, you can change signal polarity using TIMx_CCER.CCxP bits.
JW
2024-05-30 09:58 AM
Thank you both @Sarra.S and @waclawek.jan