I've been testing some time keeping code which uses timer1 to create an interrupt running at 200 Hz. When I select timer 1 prescale = 1 the code runs 100-percent accurate but if I use a different value in the prescaler it causes an error of around 0.8%
This doesn't seem logical because I wouldn't expect there to be an error where the timer misses clock pulses caused by some kind of synchronisation error. I assume the clock pulses are fed into a hardware divider, the prescaler, which would not cause any error.
Has anyone else ever come across a problem of this sort before?
Clock is derived from 8 MHz crystal. CPU is running at clock ÷ 32 giving CPU speed of 250 KHz. Chip is ATMega48.
The interrupt routine is simply a return which releases the CPU from idle state and then runs the time counting code which takes only a few instructions.
I can't think of any more details that would be helpful at the moment but please let me know if there's something else you need to know.
Thanks.
PS since the code works fine with the prescaler set at 1 I'm not stuck with this as a problem it just intrigues me as to why the error should only occur when the prescaler is not set to 1.