cancel
Showing results for 
Search instead for 
Did you mean: 

missing timer compare flags

jkuek
Associate II
Posted on May 28, 2012 at 07:21

I'm actually hunting down a weird case where sometimes the timer counter matches the CCRx register but I never see the CCxIF flag set. This seems to occur when the compare occurs when I'm in that timer's ISR handling a previous flag. I'm seeing it on the F103 and F4xx parts.

Either the flag never gets set, or it's being inadvertently cleared by software. My current suspicion is reading or writing to the TIMx_SR is causing the flag to get lost somehow, but all my accesses to that register are through bit-banding.

An example sequence of events:

1. TIM1 update  (or TIM1 CC4) event occurs. CCR4 is fixed at 0x7FFF, so this means TIM1_CNT is either 0x0000 or 0x7FFF. The value of CCR1 is set not long after this event.

2. In the ISR, while the UP (or CC4) event is being handled, the TIM1_CNT counts past the CCR1 value.

3. After the handling of the UP (or CC4), including the clearing of that flag, CC1IF flag is not set.

4. After returning from the ISR, the code goes back into the ISR for a second time, but no CC flags are set.

When the problem occurs, I never see the CC1IF flag go high. This suggests it either never goes high, or that it goes high and some other code has cleared it before my breakpoint.

I have never seen the issue occur when I step through the debugger. I can't seem to make it occur manually either.

0 REPLIES 0