2025-11-30 12:43 PM
As alread reported a while ago, strange things happen when entering an expression in CubeMX for Prescaler and/or Autoreload. If, for example, 72-1 is entered for Prescaler and 6667-1 for Autoreload, the following code will be generated:
STM32CubeMX: TIM Prescaler, Period bug
TIM_InitStruct.Prescaler = 72-LL_TIM_IC_FILTER_FDIV1_N2;
...
TIM_InitStruct.Autoreload = 6667-LL_TIM_IC_FILTER_FDIV1_N2;
LL_TIM_IC_FILTER_FDIV1_N2 does not make any sense here.
Depending on the exact values, the Timer will be initialized with some different settings than desired.
With simple constants (without calculations) the generated code will be correct.
In contrast to the previous post, in my case the MCU was a STM32F303.
CubeMX is Version: 6.15.0-RC7, Build: 20250701-1659 (UTC)