This question will be for the arduino timer guru/experts here.
You know the output compare registers, like OCRA and OCRB?
I'm trying to establish accurate details about events involving these output compare registers.
For example --- if we have a 8 bit timer, which starts counting from index 0 upwards, and if OCRA were set to a value of 45, then (if everything is configured properly to set a flag upon a 'compare match' event), then does the timer start count from index 0, then index 1, then index 2, then 3, up to index 45 ..... such that the flag that signals a 'compare match' will become '1' as soon as the count reaches 45?
I assume that if the timer is configured to be 'cleared' whenever a 'compare match' occurs, then it seems (at the moment) that a 'compare match' event will occur first. The timer value will then become 'cleared' (ie. zeroed) on the following count, after the 'compare match' event, right?
So, if an interrupt service routine is configured and triggered at the instance of a 'compare match' event, then the service routine (based on this example) will execute after exactly 45 time slots (relative to the first zero index), right? Or will the service routine execute after exactly 46 time slots?
Also ----- even though it is probably not done..... nobody ever sets a value of ZERO for the OCR value right? So setting "OCRA = 0" isn't useful, right?
A bit wordy here, so I decided to include a diagram as well. I didn't include labels like OCR2A (linked to timer numbers), just to keep things simple --- so just used labels like OCRA.
One more small question..... when the timer is set up to be cleared on a 'compare match', then the timer will be cleared on the next count. Will that clearing of the timer be the same as an overflow? Will that be the equivalent of a timer overflow condition (a TOV)?
Thanks for any replies in advance!