2021-12-13 03:22 PM
Hello,
on a STM32G474 I use "Basic timers" (TIM6, TIM7), as well as a "General Purpose Timer"(TIM4).
For the "Basic Timers" I setup I2C devices an then enable the "Basic Timer"-Interrupt by calling HAL_TIM_Base_Start_IT . That works and the HAL_TIM_PeriodElapsedCallback is not called before HAL_TIM_Base_Start_IT was called.
I have the issue that I have calls of the HAL_TIM_PeriodElapsedCallback that come from TIM4 before I called HAL_TIM_Base_Start_IT, may I have the wrong config, or do these timers and the HAL work differently in that aspect?
I admit I find ST's documentation confusing and the Timer-Parameters hard to understand, even the cookbook, so if there is alternative documentation with examples, it would be nice if you could share that as well.
Thanks a lot in advance.
Best regards, Seppeltronics
2021-12-13 04:12 PM
TIM4 works the same as other timers in regard to interrupts.
HAL_TIM_Base_Init generates an update event, which will call the interrupt if it's enabled. But it shouldn't be enabled when you call that function.
Debug the code, pause when HAL_TIM_PeriodElapsedCallback is called from TIM4 and look at the state of the TIM4 registers. Check to see if UIE is set and if so, figure out what is setting it.