cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 General Purpose Timer: Interrupt-Enable

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

0693W00000HoTzVQAV.png0693W00000HoTzaQAF.png

1 REPLY 1
TDK
Guru

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.

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