AnsweredAssumed Answered

unexpected behavior? not able to clear TIM_IT_Update

Question asked by yun.yan on Aug 19, 2014
Latest reply on Aug 19, 2014 by yun.yan
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?

Outcomes