AnsweredAssumed Answered

CubeMX incorrect systick using TIM6

Question asked by merello.andrea.001 on May 24, 2017
Latest reply on Nov 14, 2017 by Evgeny Erlihman

CubeMX (latest version: 4.21.0) advises NOT to use the 'systick' clock has HAL systick source when FreeRTOS is used (a message box pops up when generating code). So I switched to TIM6.


When doing this the generated code seems buggy: in the main() function a call to HAL_Init() initializes the TIM6 and it queries the HAL for the current PCLK clock to do so. However, since SystemClock_Config() is called only later on in main(), the PCLK clock will change and we end up in a wrong systick frequency. In my case it ended up in 50uS instead of 1mS.


This happened generating code for stm32l476, and it became very evident when using the IWDT: despite it relies on LSI clock, the SW initialization code relies on HAL systick for register write timeouts. It failed and ended up in an error handler.


Using the 'systick' clock as HAL systick seems not affected  (BTW why doing this is discouraged by CubeMX?)