I'm using STM32CubeIDE to write an application for a STM32F411RE Nucleo board. The code involves the use of a timer. When I attempt to build my project, I get a number of "undefined reference" errors for the timer functions called.
After looking around, I noticed that the timer functions (ex: HAL_TIM_Base_Init()) related to the errors are located in stm32f4xx_hal_tim.c and are grayed out with a strike-through. I assume this is the cause of the undefined reference errors I'm seeing.
Based on my googling, my understanding is that the strike-through means the function is deprecated. However, I'm unable to figure out how to resolve this. I did come across another question that's somewhat related to my issue: What would cause my source files to be greyed out with a strikethrough through the file icon?. However, the solution to it was related to the source file, rather than the functions within the source file.
Screenshot of what I'm seeing:
I'm new to the world of STM32 and STM32CubeIDE so any help/explanation is greatly appreciated. Thank you
The functions are grayed out because a preprocessor directive is not met and therefore these functions are discarded during compile time.
If you look in the file you will find something like these at the very beginning:
#ifdef HAL_TIM_MODULE_ENABLED
The STM32 HAL is designed to be able to enable or disable several modules explicitly.
And these definitions are located in the stm32l4xx_hal_conf.h
file.
Just open this file and find the HAL_TIM_MODULE_ENABLED
definition and remove the surrounding comment block.
Moreover the config file is autogenerated in the CubeIDE depend on the selected "Pin & Configuration" settings (ioc file). Also check these to enabled the timer module.