2014-08-18 04:01 PM
Hi, I am not able to clear a timer update flag while the timer is enabled. I am initializing a timer and the behavior is the following:
.... TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure); TIM4->SR = (uint16_t)~TIM_IT_Update; // clear update flag the flag was cleared ... TIM_Cmd(TIM4, ENABLE); this sets all IT flags (update, cc1, cc2, cc3, cc4), why? I initialized cc1 with a large number, so it cant be hit by the initial counter value TIM4->SR = (uint16_t)~TIM_IT_Update; // clear update flag the flag was NOT deleted TIM_Cmd(TIM4, DISABLE); TIM4->SR = (uint16_t)~TIM_IT_Update; // clear update flag now the flag was deleted What could be the reason for this behavior?2014-08-18 04:33 PM
ps: I am stepping through the code and I am watching the status flags after executing each line.
2014-08-18 04:44 PM
Is it possible that immediatly after clearing the flag the controller is setting the flag again (while debugging the timer is still running) so that I can not see the cleared flag?
2014-08-18 04:54 PM
Yes, that was the problem :)
btw, I know that one can stop the timer while debugging the controller, but I use that seldom and I always forget the running timers..