Many times in the forums I have seen people asking for a real time clock based on the internal timers of the PIC. Several implementations of the version supplied by Neutone can be found in the discussion forum but not here in the code forum so I decided to add a new topic.
I like this algorithm because it is very accurate (zero drift) even when your clock frequency is not a multiple of 256Hz. Most algorithms configure the timer to generate an interrupt every 100ms, and then count the number of times the interrupt occurs. The problem in that approach is that with nice round clock frequencies like 16MHz you can't get an exact 100ms and the small error will count up to an error of several seconds a day. The algorithm presented here doesn't count the number of interrupts but counts the number of clock cycles which makes it very accurate in the long run.
Any help will be apprecited.
I didn't find the right solution from the Internet.