There's a similar case with the RTCIFG: You should clear the IFG before you start waiting for the RTC: RTCIV = RTCIV_RTCIF ; // clear stale IFG = 1", in case the switch bounces very fast. (b) The counter_timer test should also be ">=", though you're much less likely to trip over that one. (c) After the timeout, you should clear the counters after clearing RTCIE (and before setting P2IE), in case one more interrupt sneaks in in between and throws counter_timer off.
↧