2016-01-20 10:57 AM
We have a design that drives 12 LEDs using PWM outputs spread out over five different timers on a STM32F We further control the LED dimming by turning the PWMs ON and OFF from a timer interrupt handler.
I've found that sometimes turning a LED on or off will affect a different LED. I'm wondering if I'm doing the right steps in my interrupt handler. Because the PWMs in question may or may not be running when the interrupt fires, I do the following to turn them ON: (Example is for channel 1 of TIM15)if (htimpInstance->CCR1 != 0) {
TIM_CCxChannelCmd(htimpInstance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
}
And then this to turn the PWMs OFF:
TIM_CCxChannelCmd(htimpInstance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
Does this seem correct (and safe to do in an interrupt handler)?
2016-01-20 12:15 PM
Disabling in this way cause set pin in high impedance.
Stop timer, and set pwm duty to 0 or max depending on output polarization.2016-01-23 04:16 AM
2016-01-23 06:47 AM