Two reasons: 1. Your crystal is not 1.00000000000000MHz! Most crystals has an error of 20 to 50 ppm. That is parts per million or 50 ticks/million. A little math is an eye opener. 20 hours = 20 * 60 * 60 seconds = 72000 seconds. You see a 5 second error so you count 72005 instead of 72000 or 1.000069 times too many counts. Subtract 1 and mult by 1 million and you get 69 parts per million. This is not too far off the spec. 2. If you don't put the 22pF caps on the crystal the oscillator will not be very stable. The clock will run without them but I have found that the error rate is much higher than advertised. One point that I have found is that there seems to be an error but it seems constant. What I have done is to add a software trimmer to have my interrupt routine only count interrupts every N out of M interrupts. For example every 255 out of 256 to slow the clock down or to speed it up have it add a tick every 256 interrupts. Back in the old days we would buy a 22pF trimmer cap and use a screw driver to tune the frequency. Today you can do it with software. The other fun fact is that the frequency of the oscillator is temperature dependent. Years ago folks would put their crystals in mini crystal ovens and regulate the temperature to get a very stable source. I hope that this helps. -- View this message in context: http://www.nabble.com/-PIC--TMR2-Not-keeping-Time--tf1955497.html#a5365920 Sent from the MicroControllers - PIC forum at Nabble.com. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist