AnsweredAssumed Answered

Why is a clear of the UIF for TIM after TIMinit necessary?

Question asked by Benjamin Brammer on Jun 1, 2017
Latest reply on Jun 4, 2017 by waclawek.jan

Hi Guys,

iam using the NUCLEO-F446RE to check on some routines for a custom board I am developing.

right now I am using the TIM2 to implement a simple button debounce in software.

But what puzzles me is the fact, that after the TIM2 initialization via HAL (made by CubeMX) the UIF is set, which results in an immediate jump into the TIM2 ISR routine after i started the timer via HAL command. Why is that?
Off course I can solve the problem by clearing the UIF bit prior in starting the TIM2 and then everything works fine.

But I doubt that this is wanted, or am I missunderstanding here something?

 

Another thing that quite puzzles me, is when I want to step through the HAL_TIM_IRQHandler() routine in debug mode, it seems as if the STM32 doesn't jump into the correct if instructions. So for example the UIF is being checked but not stepped into the routine for clearing Also the register I/O view is not updated automatically, I allways have to update it manually to see if the bits are really cleared or not.

 

I tested my program without my manual clearing of the UIF bit which should be handled by the HAL_TIM_IRQHandler() function. But if I don't implement this, my program is not working. So the HAL_TIM_IRQHandler() is not working.

Anyone has an explanation for this?

 

best regards

 

Benjamin

Outcomes