2021-02-02 5:36 AM
Hello,
My timer PWM channel is connected directly to a mosfet driver. By using
TIM_Cmd(TIM2, DISABLE);
it puts the output at high level. I tried to use TIM_DeInit(TIM2); but it generates an additional pulse in the output ( I count the each PWM pulse in interrupt and I disable timer in the interrupt routine). So I need to know what is the best way to disable a timer to put it at low level while it is disabled.
Solved! Go to Solution.
2021-02-02 5:48 AM
You can set a PWM channel to a fixed oputput level using the OCM (Output compare mode) bits of the capture/compare mode register, see reference manual. Don't know how that maps to your library.
2021-02-02 5:48 AM
You can set a PWM channel to a fixed oputput level using the OCM (Output compare mode) bits of the capture/compare mode register, see reference manual. Don't know how that maps to your library.
2021-02-02 6:06 AM
Thank you for your comment. I think I've done your comment with SPL library ( TIMOCStruct.TIM_OCPolarity to TIM_OCPolarity_Low and even TIM_OCPolarity_High) but nothing works. I changed CCMR1 to TIM_ForcedAction_Active(0x0050) it works fine but I see an additional pulse in the output(before the last pulse I changed the CCMR1 to 0x0050)
2021-02-02 7:46 AM
Depends on when you change the bits?
2021-02-05 12:21 AM
Another solution may be to change the given CCRx to 0 or maximum (depending on which PWM mode you are using), while using CCRx preload. This should transition cleanly, whenever written, although the result is delayed one timer cycle.
JW
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.