View Single Post
Old 07-21-2013, 03:49 PM   #32 (permalink)
nickdigger
EcoModding Apprentice
 
Join Date: Aug 2009
Location: terra firma
Posts: 138
Thanks: 4
Thanked 24 Times in 22 Posts
Quote:
Remember also that if you happen to read TCNT2, it might roll over and overflow right before you read it, thus giving a false lower value. This is why it's generally better to read the value, check for overflow condition, then read again and adjust for the overflow if the overflow condition is found to exist. All this, of course, is done while interrupts are disabled.
Looking at this again, I thought cli also shuts off timers, thus preventing any undesired counter hijinks.
  Reply With Quote