Hi Kayode If you have enough time in your processing loop you could run with no prescaler. This would give 3906.25 interrupts per second. Count down 3906 counts for seconds 1, 2, and 3 and 3907 counts for second 4. This does not leave a lot of time for other things, but if you are waiting for the timer this may not matter. Maybe you should use a 4.9152 MHz crystal with a prescale of 64 which gives 75 interrupts per second. If you are stuck with a 4MHz crystal try using a prescale of 64. Use standard seconds of 61 counts and 'leap' seconds with 62 counts. You will need to use 2 leap second every minute plus one leap second every 9 minutes. This will put you well under the stability of the crystal. My calculations show a deviation of 2.5 counts or .04 seconds per day. The worst error should be around 2 counts or 1/30 second. It could be up to 3 counts if you don't distribute the leap seconds properly. i.e.: insert leap seconds at second count 0, 30, and (every 9 minutes) at 45. I hope this helps Dave ----- Original Message ----- From: Kayode Ayandokun Sent: Tuesday, June 29, 1999 8:13 PM Subject: Re: Real time clock code > > G'day. In one of my projects, I need to know the elapsed time quite > > accurately (assume it is a clock display - it isn't but the clock is easy > > to talk about). > > > > Using a 16F84 with a 4 mHz xtal. Now if I set the prescaler to 256, and let > > the timer interrupt, I'll get an interrupt every 65,536 (256*256) usecs, > > which is not the easiest number to use to count seconds. (It will interrupt > > 15.25879 time a second) > > > > The "obvious" way is to periodically correct the time to take into account > > the odd interval. > > > > Has anyone got code (or algorithms) to do this? > >