2020-12-18 08:13 AM
I'm trying to setup single-pin, unpiolar PWM Generation outputs on Timers 8, 16 and 17 of my STM32 MCU (STM32F303RBTx). I am using the latest version of STM32CubeMX and the STM32CubeF3 firmware package as of today (Dec 18th 2020) to generate the appropriate configuration code. Attached you will find the firmware that I used to test the PWM outputs, as well as the STM32CubeMX file and screenshots of the PWM configurations.
When I disable the Automatic Output State parameter while keeping the TIM Break Input parameter disabled in STM32CubeMX, I am getting no signal from the PWM pins. However, when I enable the Automatic Output State parameter without changing anything else in the code, the my logic analyzer picks up the PWM output with the correct frequency and duty cycle (100Hz and 50%, respectively).
The following is the only code that I have added inside the main() function:
LL_TIM_CC_EnableChannel(TIM8, LL_TIM_CHANNEL_CH3);
LL_TIM_CC_EnableChannel(TIM16, LL_TIM_CHANNEL_CH1);
LL_TIM_CC_EnableChannel(TIM17, LL_TIM_CHANNEL_CH1);
LL_TIM_EnableCounter(TIM8);
LL_TIM_EnableCounter(TIM16);
LL_TIM_EnableCounter(TIM17);
The Prescaler, Auto-Reload Register and Compare values are part of the generated code (10, 65454 and 32727, respectively). The timebase frequency is 72MHz.
With the TIM Break Inputs disabled on all three timers, why is the Automatic Output State parameter affecting the PWM output signal? Thanks.
2020-12-18 10:34 AM
Hello
By setting the AOE bit in BDTR reg , forces output to enabled state in the next update event
2020-12-18 11:53 AM
Hi @Vangelis Fortounas ,
That makes sense, but I guess my next question for you is shouldn't the MOE bit be set by default or set in the generated STM32CubeMX code in the event that both break inputs are disabled? This confused me for a little while since I got the PWM output generation working on TIM3, but now I realize that TIM doesn't have a BDTR register.
Thanks for your prompt reply!
2020-12-19 07:02 AM
> shouldn't the MOE bit be set by default or set in the generated STM32CubeMX code in the event that both break inputs are disabled?
It's enabled within HAL_TIM_PWM_Start. You chose LL, so the system expects you to be fluent at the register level with what is needed to enable outputs.