2024-08-20 04:20 AM
Hi,
Something seems to be wrong with STMCubeIDE Version: 1.16.0 Build: 21983_20240628_1741 (UTC) with an STM32G070RBT6. After generation of the code, the Timer code is like this:
When we call HAL_TIM_IC_Init() function, the htim->State is already set to HAL_TIM_STATE_READY instead of HAL_TIM_STATE_RESET, so HAL_TIM_IC_MspInit(htim) is never called.
So the interrupt is not triggered, HAL_TIM_IC_CaptureCallback() is never called too.
Is my analysis right?
Solved! Go to Solution.
2024-08-21 04:15 AM
I've solved the problem.
The MX_NVIC_Init() function called in main does the same thing as the HAL_TIM_IC_MspInit() function, but without testing htim->State.
With the correct NVIC initialization:
/* TIM3_IRQn interrupt configuration */
HAL_NVIC_SetPriority(TIM3_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM3_IRQn);
Now it's OK.
Thanks for your help.
2024-08-20 05:32 AM - edited 2024-08-20 05:36 AM
htim3 is zero-initialized at the start, which sets its state to HAL_TIM_STATE_RESET. Must be something else going on here. Perhaps show your full main.c code. You could set a watchpoint on htim->State to see where it's being modified.
Edit: Oh, I see it gets set to READY in HAL_TIM_Base_Init. Yeah, you may be right. Sorry for noise.
2024-08-21 04:15 AM
I've solved the problem.
The MX_NVIC_Init() function called in main does the same thing as the HAL_TIM_IC_MspInit() function, but without testing htim->State.
With the correct NVIC initialization:
/* TIM3_IRQn interrupt configuration */
HAL_NVIC_SetPriority(TIM3_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM3_IRQn);
Now it's OK.
Thanks for your help.