2020-07-25 12:17 PM
Hi !
I need to overwrite the "normally" weak defined generated function HAL_TIM_PeriodElapsedCallback().
But if a timer other than SysTick is used as Timebase Source (which is recommended when FreeRTOS is used) than STM32CubeMx is generating this function directly in main.c without the weak property.
Therefore I'm looking for a macro or definition which can be used at compile time to know which timer is used ...
Thanks !
Michael.
2020-07-25 06:15 PM
I don't think that's something that gets put into a #define anywhere.
2020-07-26 12:14 AM
I think the same. 2 ideas:
2020-07-26 02:59 AM
For this I define "user constants" in Cube projects. They become defines in main.h.
Like #define USE_HAL_TIMER 6
Then in C file:
#if USE_HAL_TIMER == 6
….
#elif USE_HAL_TIMER == 1
...
#endif
> Don't let STM32Cube generate that specific timebase source but init a periodic TIM of your own choice and add your own implementation of HAL_TIM_PeriodElapsedCallback
A good idea for optimization; HAL_TIM_PeriodElapsedCallback is quite heavy. But IMHO you can only hack the TIM interrupt handler in stm32....it.c and let Cube generate initialization and whatever it wants. Linker will discard unused functions.
-- pa
2020-07-27 04:33 AM
This setting can be found in .ioc file. Use a text editor to inspect the ioc file
2020-07-27 09:03 AM
Hi Pavel,
thanks for your feedback.
That's exactly the way I'm doing it currently. My hope was to find a macro to eliminate that error prone step.
2020-07-27 09:08 AM
That's true but this information must be provided to the gcc compiler somehow - too much effort writing a tool for this ...