cancel
Showing results for 
Search instead for 
Did you mean: 

Weird behaviour on PWM outputs

RobK1
Senior II

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?

2 REPLIES 2
waclawek.jan
Super User

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


@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.