I'm working on a simple count-down timer that will time from 0.1 to 999 seconds with 0.1 second resolution. I'm using an Atmel ATmega8515, probably not the best chip but I have a ton of 'em from another project.
My problem is, it's not behaving anything like I expect. Up to about 10 seconds, the time interval is about a tenth of a second too long. Between 11 and about 60 seconds, it's spot on. At 999 seconds, it has lost 3 seconds. I'm doing things rather conventionally. Timer 0 is set up in CTC mode to count down the 16MHz clock at 1ms intervals. There's a state machine that stores what the timer is doing (idling, being set, counting, finished, etc) but the actual assertion and de-assertion of the output pin is done in the ISR. It should therefore have millisecond accuracy. The erroroneous time is repeatable from one run to the next down to the millisecond so I know that I'm not missing interrupts. I've also verified that by toggling an unused pin inside the ISR and timed it with a high precision HP counter/timer. So my first question to the list is, can you point me to some Atmel clock code in C that I can study to see what I might be doing wrong? Later I may post the code and ask for someone to look at it but I really want to solve this problem for myself. This is a timer for our (Fluxeon's) Roy induction heater but I plan on open sourcing the thing - hardware and software - once I get it working. So it needs to work right AND the code has to look good :-) Thanks. John -- John DeArmond Tellico Plains, Occupied TN http://www.fluxeon.com <-- THE source for induction heaters http://www.neon-john.com <-- email from here http://www.johndearmond.com <-- Best damned Blog on the net PGP key: wwwkeys.pgp.net: BCB68D77 -- You received this message because you are subscribed to the Google Groups "neonixie-l" group. To unsubscribe from this group and stop receiving emails from it, send an email to neonixie-l+unsubscr...@googlegroups.com. To post to this group, send an email to neonixie-l@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/neonixie-l/52781CA1.2060803%40neon-john.com. For more options, visit https://groups.google.com/groups/opt_out.