A member of the Forum was kind enough to send me the attached code for reading the time from a DS1302 clock chip. I am using the code in a real time application program and I noticed that, after a few days, events were happening later in time. After a week the clock was 45 seconds slow. I changed the DS1302 with three other chips and noticed the same effect was present. I changed the crystal with three other crystals and the clock time was slow by the same amount. The time is read in a fast loop continually. The hours, minutes, and seconds are compared to start values in the loop. When a match occurs, outputs are set or cleared.
I changed the PAUSE instruction from PAUSE 1 to PAUSE 10 and noticed the clock ran slightly faster. Is there a fix to this code?