Hi John,
I haven't done anything with AVR chips in a couple of years now, but
I can only add that I've felt your pain. I built a lot of clocks using
AVR parts, in a variety of designs and with a variety of AVR chips...
and they all had strange repeatable timer issues. I do think that the
AVR parts might miss interrupts on occasion... are you disabling the
timer interrupts at any point in your code? I think that you usually
need to disable interrupts when interacting with i2c parts, etc...
-disable interrupt
-dump command to peripheral part
-enable interrupt
Like that... and that sort of thing is what I always assumed was the
culprit. Eventually, I decided that it simply wasn't worth it for me to
implement solid clock code in AVR and switched to using standalone clock
chips. I like the Maxim DS1307, since it comes in 8-pin DIP package and
is i2c. That way, I can worry about the fun functionality in my AVR code
and leave the dreary clock accuracy optimization to the birds.
FYI, I did find that my clock accuracy increased if I lowered the
frequency of the AVR. 12mhz ATTiny2313 was much less accurate than the
same part with the DIV8 fuse set. I assume because a 1.5mhz clock AVR
would need to interrupt far less often in order to generate the desired
0.1 second resolution.
-Adam
On 11/4/2013 2:16 PM, NeonJohn wrote:
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
--
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 [email protected].
To post to this group, send an email to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/neonixie-l/52782A73.8010304%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.