Timer2 oddness on Uno r3

Hello, I'm playing around with Timer2 on an Uno r3, trying to figure out timings and when flags are set and such.

I've got it in mode 7, fast pwm with OCR2A as top, clock divided by 8 for clock select. As far as I can tell, after the clock has been at the value of OCR2A for 8 cycles, it then resets to 0 on the next cycle, then one cycle after that, the TOV2 flag will test as set (same for OCF2A flag). Can anyone confirm this, or point me anywhere? That would be good to know, but it isn't the main thing I have found..

With the following snippet:

  "waiting: \n"
  "  sbis    TIFR2, TOV2     \n"
  "    rjmp waiting    \n"
  "    sbi TIFR2, TOV2 \n"

  "  sbic    TIFR2, TOV2     \n"
  "    rjmp surelythisshouldneverhappen    \n"//with reasonable values for OCR2A?

Should it be possible for the jump to ever happen, with all interrupts disabled (and >10 times for OCR2A)? Or is there some weirdness with the flag being set twice when there is a divider on the clock, if the flag is cleared quickly enough?

Trying to come up with a simple thing to demonstrate this right now...

Which relationship between interrupts and jumps do you suspect?

I was an idiot, so that part isn't the issue (the condition that i was causing at the surelythisshouldneverhappen jump, to test for later, was being caused by something else), however I'm still having the issue that I was trying to track down. Trying to make a simple thing that demonstrates that now. I'm increasing OCR2A WELL before the timer gets to it, yet it is still overflowing/setting flag at the old value.. I'll try to get a thing together to post.

ah really? is that what that means, the double buffering, i mean? I often find it pretty hard going trying to understand what they mean in the doc, I've read it tons of times... If that's the case, then great (i think), should be able to sort it out (I hope!), thanks! I'll post back once I've got somewhere...

I think.... that that was the whole problem!... seems so, though i don't have a good enough oscilloscope to know for sure, I'll have to wait, but it sure seems so! Thanks a lot!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.