cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX timer period value generated wrong

Rafael Bachmann
Associate II

CubeMX generates weird number for timer period.

I set the timer period to 0xffffffff in the GUI. That results in CubeMX setting:

4.294967295E9

for the period. That value is wrong. It should be just 4294967295.

Is that a CubeMX bug?

4 REPLIES 4

Hello @Community member​ 

Could you please explain more your request (the scenario) (which MCU) to check the issue.

Please share your ioc file to check the problem.

Best regards,

Nesrine

TDK
Guru

4.294967295E9 and 4294967295 are equal. One is expressed in scientific notation. Though certainly an integer would be preferable here.

If you feel a post has answered your question, please click "Accept as Solution".
Rafael Bachmann
Associate II

Hello Nesrine,

I am using stm32g474ve on STM32CubeIDE v1.4.0.

In the .ioc file, TIM2.PeriodNoDither is set correctly to 0xffffffff. But the generated code has this line:

  1. /* TIM2 init function */
  2. void MX_TIM2_Init(void)
  3. {
  4. TIM_ClockConfigTypeDef sClockSourceConfig = {0};
  5. TIM_MasterConfigTypeDef sMasterConfig = {0};
  6.  
  7. htim2.Instance = TIM2;
  8. htim2.Init.Prescaler = 99;
  9. htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
  10. htim2.Init.Period = 4.294967295E9;
  11.  
  12. ...

Best regards,

Rafael

Hello @Community member (Community Member)​ 

4.294967295E9 and 4294967295 are equal.

Best regards,

Nesrine0693W000003PTpyQAG.png