# How to improve I2C RTC accuracy

I´m using a PCF 8583 I2C RTC for one of my projects (i´m not a professional, just an amateur). The clock delays about an hour per day, which I find unacceptable.

I´m using a 32768 Hz, 12.5 pf, 50 Kohm crystal with the RTC. Acording to the datasheet, the capacitance is OK (5 min, 20 max, 10 typical), but the resistance is a bit high. They don´t provide minimum nor typical values for that, but state a maximum 40 Kohm for the crystal.

Can this be the cause?

I personally think something else must be wrong. I used the same components and program code for another project, and it is not as bad as this one (it also delays, but about 3 minutes per day).

My last effort was to add a wire connecting the crystal package to ground. It improved, but not enough.

Any thoughts on how to improve accuracy?

• Have you measured the actual crystal oscillation frequency? – Ignacio Vazquez-Abrams Aug 23 '13 at 6:27
• Did you take into account your ground layout under/around the crystal? – Passerby Aug 23 '13 at 6:40
• Thanks both of you for your comments. I´m afraid the datasheet did not provide any information or warnings about PCB routing / grounding, so, I didn´t do it. That´s problem Nº1. I´ll fix it. Ignacio, I don´t have an oscilloscope yet, so I haven´t measured the frecuency. Anyway, the first thing I did was changing the crystal, so the problem is not in this particular part. – user27872 Aug 23 '13 at 7:09
• @user27872 its because NXP has that information in a secondary datasheet. ics.nxp.com/support/documents/interface/pdf/… Maxim has the same info on their primary datasheets. But I think the ground plane under a crystal is a standard practice issue, not always explicitly stated. – Passerby Aug 23 '13 at 7:33
• Did you try changing the adjustment capacitor value? What type of cap did you use? Can you please add the layout around this IC? – Szymon Bęczkowski Aug 23 '13 at 7:34

3 min per day is:

$$24\cdot60= 1440min$$

$$\frac {3}{1440}= 2083ppm$$

Your Xtal is more than 2000ppm off its nominal frequency. Even here there is an issue. But 3 hours per day is more than 4% ! There is a design issue here. For sure.

The Xtal frequency depends on the load capacitance and this is the common root cause of a wrong frequency.

Are you sure you computed your C1 and C2 correctly? The formula is:

$$C_L = \frac {C_1 C_2}{C_1+C_2}+C_{stray}$$

With

• CL = the load capacitance given by the manufacturer
• C1 and C2 = The added capacitors on the xtal pins
• Cstray = the stray capacitance of the tracks, pins etc...

If you have access to a spectrum analyzer, you may measure the frequency of the xtal using a near field probe (don't touch the xtal tracks with a probe, it changes the capacitance and thus the frequency) and adjust the load capacitors to get the correct frequency.

EDIT:

In the PCF8583 datasheet of NXP: "Chapter 11.1 Quartz frequency adjustment". It is explained here that you should add an external capacitor to your Xtal to fine tune the frequency.

• Thanks a lot for your reply. The datasheet for this particular part states that no external capacitors are required, so I connected the crystal directly to OSC-I / OSC-O pins. That puzzled me, since I thought theese capacitors could be used to fine-tune the actual frequency if needed. Right now I´m reading microchip´s excellent Aplication Note 826 (should have done this before...). I will incorporate what I learn to the design, and let you know. – user27872 Aug 23 '13 at 7:23
• Pay attention to the config fuses as well. They need to match your oscillators so it can be correctly driven – Scott Seidman Aug 23 '13 at 10:43
• I don't understand the formula of the load capacitance: (C1*C2) / (C1*C2) equals 1 ! – Dor Aug 23 '13 at 14:04
• @Dor I fixed it. – Matt Young Aug 24 '13 at 3:53