Timebase source other than Systick uses unconfigured clock configuration
- 4 replies
- 2301 views
When changing the timebase source in CubeIDE from Systick to any peripheral timer (TIM6 in my test case), the timer is set up in HAL_InitTick() called from the HAL_Init() function, which is the first function that is called in main().
HAL_InitTick() uses several calls to get the clock configuration from RCC in order to set up the timer.
However, the clocktree is configured only AFTER the timer has been initialized, since SystemClock_Config() is the second function called in main().
This should mean, that the peripheral timer that provides the system clock is based on uninitialized clock settings.
The simple solution is to swap SystemClock_Config() and HAL_Init() in main(), so clocks are configured first and the timer afterwards.
Am i missing anything, or is this a bug?
Setup:
STM32F427VGTx
CubeIDE 1.16.0
STM32Cube FW_F4 V1.28.0
Selected Timer for System clock source: TIM6
My .ioc file is attached.
