stm32duino / STM32FreeRTOS

Real Time Operating System implemented for STM32
312 stars 61 forks source link

Is it a good practice to change HAL time base to timer and free SysTick for FreeRTOS? #66

Closed jancotipsarevic closed 1 year ago

jancotipsarevic commented 1 year ago

Hello all, I am starting playing with stm32duino + freertos + cmake + CLION and everything is working fine but I have doubt. In my previous work with stm32cubeide + stm32cubemx + freeRTOS it was recomended to change HAL time base to any available timer and free the Systick for FreeRTOS, I have tried to do so but it looks no ovbious to redefine HAL_TIM_PeriodElapsedCallback function.

It has sense what I am trying to do, is it possible? I will appreciate any hint on that matter. Thank you very much.

fpistm commented 1 year ago

Hi @jancotipsarevic, by default HT is used by Arduinon API, which explains why you can't redefine the HAL_TIM_PeriodElapsedCallback. To be able to redefine it, you have to disable the HT support for the Arduino API as explained here https://github.com/stm32duino/Arduino_Core_STM32/wiki/HAL-configuration#hal-module-only So defining HAL_TIM_MODULE_ONLY will allow to redefine HAL_TIM_PeriodElapsedCallback, pay attention to add extern "C" if you redefine it in .ino or .cpp.

About the "sense", I'm not an expert of FreeRTOS. Here, it is just a port as an Arduino library format of the STM32 FreeRTOS version. All is explained here, the SysTick_Handler is used to called the osSystickHandler https://github.com/stm32duino/STM32FreeRTOS/blob/f3abddcd420bd92a862b35877181392bd2647b2a/src/FreeRTOSConfig_Default.h#L218-L224

https://github.com/stm32duino/Arduino_Core_STM32/blob/2e754893e1c5d43096558e8e973ccf5d741a28b1/libraries/SrcWrapper/src/stm32/clock.c#L59-L70

Anyway, you are free to override all of this as it is purely configuration.

jancotipsarevic commented 1 year ago

Excellent answer you put me on track, thank you very much.

El lun, 17 jul 2023 a las 11:50, Frederic Pillon @.***>) escribió:

Hi @jancotipsarevic https://github.com/jancotipsarevic, by default HT is used by Arduinon API, which explains why you can't redefine the HAL_TIM_PeriodElapsedCallback. To be able to redefine it, you have to disable the HT support for the Arduino API as explained here https://github.com/stm32duino/Arduino_Core_STM32/wiki/HAL-configuration#hal-module-only So defining HAL_TIM_MODULE_ONLY will allow to redefine HAL_TIM_PeriodElapsedCallback, pay attention to add extern "C" if you redefine it in .ino or .cpp.

About the "sense", I'm not an expert of FreeRTOS. Here, it is just a port as an Arduino library format of the STM32 FreeRTOS version. All is explained here, the SysTick_Handler is used to called the osSystickHandler

https://github.com/stm32duino/STM32FreeRTOS/blob/f3abddcd420bd92a862b35877181392bd2647b2a/src/FreeRTOSConfig_Default.h#L218-L224

https://github.com/stm32duino/Arduino_Core_STM32/blob/2e754893e1c5d43096558e8e973ccf5d741a28b1/libraries/SrcWrapper/src/stm32/clock.c#L59-L70

Anyway, you are free to override all of this as it is purely configuration.

— Reply to this email directly, view it on GitHub https://github.com/stm32duino/STM32FreeRTOS/issues/66#issuecomment-1637731217, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIN5CVW45HX5X43LNELLLJTXQUDGPANCNFSM6AAAAAA2L4OHRQ . You are receiving this because you were mentioned.Message ID: @.***>

fpistm commented 1 year ago

Welcome. I close it as considered answered.