STM32 gotchas
231.LPTIM PWM cannot be set to steady 0 nor 1, unlike TIM PWM

In the "normal" STM32 timers, when set to one of the PWM modes, if TIM_CCRx = 0, corresponding output is at one steady state, and if TIM_CCRx >= TIM_ARR + 1, output is at the other steady state. TIM_CCRx values in between 1..TIM_ARR correspond to pulse lengths of 1..TIM_ARR, while the PWM period is (TIM_ARR + 1).

LPTIM works differently.

Values of LPTIM_CMP between 0..(LPTIM_ARR - 1) correspond to pulse lengths of 1..LPTIM_ARR while the PWM period is (LPTIM_ARR + 1) 1. It is prohibited to set LPTIM_CMP to or above LPTIM_ARR.

This means, that steady states cannot be achieved by setting purely LPTIM_CMP. This may come as an unpleasant surprise for those, who expect LPTIM PWM to be used as a direct replacement for TIM PWM.

There are several workarounds available:


1. PWM output of LPTIM corresponds to PWM mode 2 of TIM; it means, that the output is low for the first part of period and high for the second part. We call "pulse" here the first part of period. As "pulse" is usually perceived as the "high portion" of period, this behaviour can be illustrated when inverting the output by setting LPTIM_CFGR.WAVPOL to 1.