2026-06-04 5:52 AM
I'm working on a device with an STM32L072CZT. It uses Channels 1, 3, and 4 of TIM2 to generate PWM signals that control LED drivers. The LEDs blink in predetermined patterns, so the PWM is periodically switched on and off, using LL_TIM_CC_EnableChannel and LL_TIM_CC_DisableChannel, respectively.
A few weeks ago, I made some required changes to the code, but had to put finalizing off because of other priorities. Today I picked it up again, and to my astonishment, the PWM outputs behaved completely wrong. Instead of seeing PWM - 0 - PWM - 0 - ..., I saw PWM - 1 - PWM - 1 - ... In other words, rather than off, the LEDs go fully on!
The exact same code in two other devices works as expected, so the fault is not in the firmware. I am seeing PWM, so the GPIOs are OK.
So, apparently, this particular chip has somehow been damaged in such a way that the PWM logic is broken? I find that kind of hard to believe.
Has anybody ever come across something similar? Can somebody from ST maybe shed some light on this?
2026-06-04 6:01 AM
LL_TIM_CC_DisableChannel() clears the respective TIMx_CCER.CCxE bit, and that sets the respective pin to Hi-Z.
So, it depends on your hardware, how will this behave.
JW
2026-06-04 6:13 AM - edited 2026-06-04 6:17 AM
@waclawek.jan wrote:[...] that sets the respective pin to Hi-Z.
Can you point me to a reference, because I could not find anything in the RM that states this. The ports are configured as push-pull, so I can hardly imagine this to be the case.
Anyhow, it works on dozens of devices, including the one where it now doesn't work anymore. Also, the PWM signals all have a pull-down.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.