cancel
Showing results for 
Search instead for 
Did you mean: 

Why are there identical functions like "HAL_TIM_IC_Init" and "HAL_TIM_Base_Init" ?

Tobe
Senior III

These functions above are are functional identical. And they are calling weak functions "(Base/IC)_MspInitCallback" and "HAL_TIM_(Base/IC)_MspInit". "HAL_TIM_Base_Init" is actually used in my generated code and the weak function is actually replaced with a generated one in "Core/Src/stm32f3xx_hal_msp.c".

As getting into STM32 and HAL is quite a task, these duplicated functions are annoying as ****. But maybe someone knows a good tutorial with some good insight? I havent came across a good source for this topic from STM...

1 REPLY 1
Ghofrane GSOURI
ST Employee

Hello @Tobias Köhler​ 

First let me thank you for posting.

The "HAL_TIM_IC_Init" and "HAL_TIM_Base_Init" functions are similar because they both initialize timers in the STM32 microcontroller, but they have different functionalities.

1- "HAL_TIM_IC_Init" initializes the input capture (IC) mode of a timer, which is used to capture the value of an external signal at a specific time.

2- "HAL_TIM_Base_Init" initializes the timer in base time base mode, which is used to generate periodic interruptions or trigger events at a fixed frequency.

The reason for having separate functions for these modes is to provide the user with a more efficient way to control timer modes. By separating the initialization functions, the user can choose the mode to initialize according to his specific needs, without having to include unnecessary code.

Thx

Ghofrane