Skip to main content
Tobe
Senior III
April 17, 2023
Question

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

  • April 17, 2023
  • 1 reply
  • 1447 views

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...

This topic has been closed for replies.

1 reply

Ghofrane GSOURI
ST Technical Moderator
April 17, 2023

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.