I use Timer1 on 500ms interrupt routine to run code for a real time clock.
On the PIC16F628A the time is quite accurate (about 1sec drift per day). On the 16F876 it's much worse, (about 15 seconds to the hour).
Both designs are the same as far as decoupling cap on the power supplies, 4MHZ Xtal with 33pf decoupling caps.
Can anyone shed some light on why there's such a big difference between these two models of PIC? BTW, It has happened now in two applications, so it's not some random thing. With both applications where I use the 16F876 the time just "runs away"
33pf capacitors are at the high end of the microchip recommended range of values for that frequency crystal.
Try using lower value capacitors such as 22pf which usually works very well with 4Mhz crystals.
Also see this piclist info:
I feel the same way, I've had great luck with watch crystals but the faster the crystal the more they seem to drift. I recall another thread where I was told this is a misconception.
So, the accuracy of the crystal has nothing to do with the oscillation frequency? Any proof saying that the slower the crystal, the better accuracy it has?
Well if a crystals quality is measured in PPM (parts per million) then a slower crystal with the same PPM would be more accurate.
You can usually tune a crystal by adding a trimcap to one of its legs.
Assuming there are no software issues:
Have you tried changing the oscillator mode in CONFIG. ie: XT vs HS mode?
As mentioned above, 15-22pf caps are the ones that MicroChip recommends for a 4 Mhz xtal.
Are you using an A-T cut crystal?
I don't know? As a hobbyist I salvage crystals from old PCB's. To be honest, in the current application I used one of those crystals with the three pins, that already has the capacitors included, but in my previous application, I used a metal case crystal with the caps as mentioned. BUT, in both applications (with the 16F876) the time was drifting.
kchriste said:
Have you tried changing the oscillator mode in CONFIG. ie: XT vs HS mode?
I don't know? As a hobbyist I salvage crystals from old PCB's. To be honest, in the current application I used one of those crystals with the three pins, that already has the capacitors included, but in my previous application, I used a metal case crystal with the caps as mentioned. BUT, in both applications (with the 16F876) the time was drifting.