cancel
Showing results for 
Search instead for 
Did you mean: 

generation issue STM32CubeMX 5.6.1 - Timer init

Renato Valentim
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
Imen GH
ST Employee

​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

View solution in original post

3 REPLIES 3
Imen GH
ST Employee

​Hello,

Could you please share your file .ioc to check ?

Regards

Renato Valentim
Associate III

Here it is.

Imen GH
ST Employee

​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