cancel
Showing results for 
Search instead for 
Did you mean: 

PWM outputs not working when Automatic Output State (TIMx_BDTR->AOE) parameter is disabled, even though TIM Break Inputs (TIMx_BDTR->BRKE/BRK2E) are disabled.

Filip Vranes
Associate II

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.

3 REPLIES 3

Hello

By setting the AOE bit in BDTR reg , forces output to enabled state in the next update event

0693W000006GLwgQAG.jpg 

Filip Vranes
Associate II

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!

TDK
Guru

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

If you feel a post has answered your question, please click "Accept as Solution".