I'm trying to understand good ways to use timers. Tell me if this is a reasonable way to do things.
Let's say I'm running at 8MHz and I want to use a 16-bit timer to measure 1 second. If I use a prescaler of 256 that means 1 second will have passed then the timer reaches 31250 (because 8000000/256=31250).
So, if I write to the TNCTx a value of 34286 (65536-31250) and reset this at every interrupt the overflow flag should trip every 1 second. Right?
My first question is: The overflow flag isn't thrown until the timer rolls over to zero. I've taken care of that but use 65536 (instead of 0xFFFF) right? In other words, am I doing the math right or have I added 1 cycle too many?
My second question: Is this better/worse/same as just using CTC mode and setting my value?
Thanks for the help.
I'm asking this in the abstract... but in case it helps. I'll be testing this out on an ATmega168 using Timer1.