cancel
Showing results for 
Search instead for 
Did you mean: 

FreeRTOS and HAL

Posted on September 15, 2017 at 10:11

I'm learning how to use an RTOS (FreeRTOS in this case) and I have a couple of questions about its interoperability with HAL. So now I have a project generated by STM32CubeMX v4.22.1 with FreeRTOS selected and some options tuned.

1. The stm32l0xx_hal_conf.h contains a definition '&sharpdefine  USE_RTOS 0U', when I change it to 1U HAL fails to compile on this line: '&sharperror 'USE_RTOS should be 0 in the current HAL release''. What does it mean? Is HAL ready to work with an RTOS?

2. For example the default (weakly defined) HAL_Delay function will not work well with FreeRTOS, I think it would be better to redefine it in the generated freertos.c file to use the osDelay function instead of wasting cycles and preventing the RTOS kernel to switch to another task. Or am I wrong?

Edit:

Redefining HAL_Delay isn't very straightforward because all the clocks and peripherals initialization in main.c is done before initializing the RTOS, so osDelay won't work in the beginning.

Edit 2:

It seems internally HAL_Delay is only called in the stm32l0xx_hal_pcd_ex.c module of the HAL (at least in STM32CubeL0), so that's not that much bad.

#freertos+hal
2 REPLIES 2
Karl Tsai
Associate
Posted on April 26, 2018 at 15:20

Forget about changing USE_RTOS as it is just a placeholder and most likely nothing will come out of it.

You may be interested to read my response here

https://community.st.com/0D50X00009XkWovSAF

Posted on April 26, 2018 at 15:40

I tend to agree.

A RTOS like FreeRTOS would like to use ressources that HAL has already carelessly hijacked.

I don't envy the developers assigned to marry both ...