cancel
Showing results for 
Search instead for 
Did you mean: 

FreeRTOS SysTick Handler issue after migration in STM32CubeIDE 1.17

FrankRidder
Associate

Background, We have projects where the SYS timebase is set to a peripheral timer. Currently, this no longer works with the new cubeMX version.

In STM32CubeIDE 1.17, migrating projects to the updated CubeMX version (6.12.0 -> 6.13.0) modifies the FreeRTOSConfig.h file in Core/Inc. Specifically, the following changes occur:

Old lines (140–143):

/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, to prevent overwriting SysTick_Handler defined within STM32Cube HAL */
#define xPortSysTickHandler SysTick_Handler

New lines (144–146):

/* IMPORTANT: After 10.3.1 update, Systick_Handler comes from NVIC (if SYS timebase = systick), otherwise from cmsis_os2.c */
#define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 0

The old configuration ensured that FreeRTOS used its SysTick implementation from port.c. Specifically, xPortSysTickHandler in port.c was renamed to SysTick_Handler, matching the function name in the startup file's interrupt vector.

With the new configuration, this renaming no longer happens. If the SYS timebase is configured to use a timer peripheral (instead of SysTick), there is no implementation of the SysTick_Handler function, leaving the interrupt unhandled. As a result, the Default_Handler is used, which prevents FreeRTOS from switching tasks. 

If the SYS timebase is configured to use SysTick in the .ioc file, an implementation of SysTick_Handler is generated in stm32f3xx_it.c. This generated function calls both HAL_IncTick and xPortSysTickHandler. This indicates that ST assumes the SYS timebase is always set to SysTick and that the use of a timer peripheral as the SYS timebase is no longer supported.

Effectively, FreeRTOS no longer works when using a timer peripheral as the SYS timebase in STM32CubeIDE 1.17 after migrating the project.

1 REPLY 1
Pavel A.
Evangelist III

Yes, in early FreeRTOS it contained the SysTick handler, but later they added co-existence with other software such as the STM32 "HAL" and assume that the handler exists in external code. So we have to keep an eye on this and fix whenever necessary.