There is some good info here;
Zero-error 1 second timing algorithm
If you look down the page there is a technique for generating very accurate 1 second periods, which will get you much better accuracy than the inherent xtal speed; if you adjust the variable after testing that xtal you can get it to a few PPM especially if used indoors where the temperature doesn't change that much.
(I cut and pasted);
---------------------------------------------------------
Advanced bresenham timing techniques
Clock xtal super-fine calibration.
The int period and 1second period value can both be multiplied by the same number, giving an increase in the timer resolution much greater than the original resolution of the xtal value in Hz.
This next example uses a PIC with 4Mhz xtal (1MHz timer), and testing against a GPS receiver over a month shows the PIC clock is 9 seconds fast. So the 1second correction value is calculated as;
(1month+9secs) / 1month which in seconds is; 2678409 / 2678400
Which is 1.0000033602
Multiply by 1Mhz to give the correct 1 second period; = 1000003.3602 ticks
Since we are using an unsigned long variable for the bresenham accumulator the same code will take a value up to 4.29 billion with no issues. So we just multiply both the periods by 1000, which gives 1000 times finer resolution to calibrate the clock but still uses the same simple C code;
Code:
//C code for PIC 4Mhz xtal (1MHz timer) super-fine calibration
// uses 1 variable; unsigned long bres
// gets here every TMR0 int (every 256 ticks)
bres += 256000; // add (256*1000) ticks to bresenham total
if(bres >= 1000003360) // if reached 1 second!
{
bres -= 1000003360; // subtract 1 second, retain error
do_1sec_event(); // update clock, etc
}
---------------------------------------------------------
If you use that code you can calibrate your 1MHz timer to .000000001 MHz resolution, and the code is very simple.