1
\$\begingroup\$

Can anyone explain to me wht is the difference between PWM1 and PWM2 in STM32F3 timer configuration? It is mentioned frequently in documentation, however I can't find the difference between these two settings. Code example for setting PWM1 OC mode for timer 8:

Tim_InitStruct.TIM_OCMode = TIM_OCMode_PWM1;
Tim_InitStruct.TIM_OutputState = TIM_OutputState_Enable;
Tim_InitStruct.TIM_Pulse = 512 / 2; // 50%
Tim_InitStruct.TIM_OCPolarity = TIM_OCPolarity_Low;
\$\endgroup\$
4
\$\begingroup\$

It is documented in the Reference Manual, at the register descriptions.

TIMx capture/compare mode register 1 (TIMx_CCMR1)

[...]

0110: PWM mode 1 - In upcounting, channel 1 is active as long as TIMx_CNT<TIMx_CCR1 else inactive. In downcounting, channel 1 is inactive (OC1REF='0) as long as TIMx_CNT>TIMx_CCR1 else active (OC1REF=1).

0111: PWM mode 2 - In upcounting, channel 1 is inactive as long as TIMx_CNT<TIMx_CCR1 else active. In downcounting, channel 1 is active as long as TIMx_CNT>TIMx_CCR1 else inactive.

In other words, the output signal is inverted in mode 2.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.