Skip to main content
Renato Valentim
Associate III
May 14, 2020
Solved

generation issue STM32CubeMX 5.6.1 - Timer init

  • May 14, 2020
  • 3 replies
  • 1013 views

When I generate for TIM9 input capture to measure a pulse width, CubeMX inserts correctly these two lines into the function MX_TIM9_Init:

 if (HAL_TIM_IC_Init(&htim9) != HAL_OK)
 {
 Error_Handler();
 }

Then in the stm32fxx_hal_msp.c file it inserts a HAL_TIM_IC_MspInit with the TIM9 stuff in it.

But for TIM10:

If I also generate for TIM10 also for input capture to measure pulse width it now inserts these lines in the MX_TIM10_Init function:

 if (HAL_TIM_Base_Init(&htim10) != HAL_OK)
 {
 Error_Handler();
 }
 if (HAL_TIM_IC_Init(&htim10) != HAL_OK)
 {
 Error_Handler();
 }

and in the stm32fxx_hal_msp.c file it inserts a HAL_TIM_Base_MspInit function instead of a HAL_TIM_IC_MspInit.

Why the 2 different behaviors for TIM9 and TIM10? I did manual code (without using CubeMX) could I get away using TIM9 annd TIM10 the same way (without the TIM_Base stuff) just sticking with HAL_TIM_IC_Mspinit for both timers?

Thanks

This topic has been closed for replies.
Best answer by Imen GH

​Hello,

Please Refer to datasheet ( Link)

According to this reference : "TIM10, TIM11, TIM13, and TIM14 feature one independent channel, whereas TIM9 and TIM12 have two independent channels for input capture/output compare, PWM or one-pulse mode output. They can be synchronized with the TIM2, TIM3, TIM4, TIM5 full-featured general-purpose timers. They can also be used as simple time bases".

Regards

3 replies

Imen GH
ST Employee
May 15, 2020

​Hello,

Could you please share your file .ioc to check ?

Regards

Renato Valentim
Associate III
May 15, 2020
Imen GH
Imen GHBest answer
ST Employee
May 15, 2020

​Hello,

Please Refer to datasheet ( Link)

According to this reference : "TIM10, TIM11, TIM13, and TIM14 feature one independent channel, whereas TIM9 and TIM12 have two independent channels for input capture/output compare, PWM or one-pulse mode output. They can be synchronized with the TIM2, TIM3, TIM4, TIM5 full-featured general-purpose timers. They can also be used as simple time bases".

Regards