Due Integrated RTC time drift

Hi all. I need to sync the RTC time and date with GPS and then, based on the RTC time drift, define intervals of synchronization to to make sure that the system will be accurate to the millisecond. During my tests, I found that the RTC of Due lose around 6us/s at 15ºC. Isn't that too much? My strategy was store the system's microseconds on the rising edge of the 1pps output of the GPS and subtract that to the microseconds on the "new second" interrupt of the RTC, store the results for over 3 hours and then compute the median of that values...

here is the RTC time loss graph...

Hope that anyone can confirm this results ;) Thanks

Have you added a 32kHz crystal to get the RTC working?

If so AFAIK they are really crap accuracy although I can't remember how many PPM you would expect.


I think that's it! I can see that the Due board doesn't have the 32.768Khz crystal oscillator specified on the SAM3X datasheet, so I have to add it on XIN32 and XOUT32 (pins 48 and 49). I think the board should come with the oscillator, since it's present on the schematic! I will add the oscillator and than report back the time drift.

Thanks for the help!

Ah yes, if you are using the internal clock that would explain it I’m sure, it is spec’d at running between 20 and 44kHz so all bets are off WRT accuracy.

As to why the schematics don’t match the board being sold, this is not the only example and we’ve commented on this several times. The answer seems to be everything from “we’re too busy to update them” to “the manufacturers can load what components they like”, both of which must be bollocks. Go figure, but (technically at least) I guess this means that the Due is not open source :slight_smile:


I believe all "official" dues except the very early ones have the crystals. Even with a crystal it is far from a precision clock if you get accuracy within a few milliseconds you are doing very well.

There are lots of counterfeit boards out there. If you bought it on eBay it is probably counterfeit.

The thing is that my board is an original Due R3 bought from an official distributor and still doesn't come with the crystal :( Off-course that if the board is counterfeit I couldn't complain...

I think I can get an error of less than 400 microseconds if I sync the RTC every minute, witch may be not that critical on my application... But i'll try the crystal anyway, since I don't have power restrictions.

When using the RTC_Clock library, one uses XTAL or RC as the argument to the instantiation call, to get the External Crystal, or the internal RC (resistor-capacitor) oscillator:

RTC_Clock rtc_clock(XTAL) ; // use RC for internal osc.

Has anybody verified that it works as expected?

Even when using the External crystal (my genuine boards all have the oscillator chip installed) I get substantial time variations, or so it seems, and the error appears to vary substantially, but perhaps my "reference" is not good?

perhaps my “reference” is not good

That’s the first question, what is your reference?

Next question is “What are ‘substantial’ time variations?”


The RTC uses a watch crystal, 6ppm is pretty good going for a watch crystal, only 4 seconds a week!

I notice that on my Due (R3) the actual crystal package has a transparent top and you can see the tuning-fork shaped piece of quartz inside!

MarkT: The RTC uses a watch crystal

hummm, so probably everything is right with my board and I just couldn't identify the crystal. I was looking to the RTC diagram on the SAM3X datasheet and I see that it choose between the crystal/RC oscillator using a multiplexer. So if the board didn't have the crystal, and I am not using the RC oscillator, then it would simply not work. It has to be there! I will check that again when I get back to it on the weekend :P

here are some data on drift of MCU crystals and RTC's including DUE https://github.com/manitou48/crystals

crystals.txt has the drift data. drift is affected by voltage, temperature, age, and capacitance. your mileage may vary.

Here are specs for MCU crystal and RTC from the DUE schematic/bom Y1,12MHz KX-7 20pF CRYSTAL-3.2-2.5 CRYSTAL-3.2-2.5 probably 30ppm Y2,32.768Khz,RESONATOR_EPSON_FC_145,RESONATOR_EPSON_FC_145 20ppm 12.5pf

OK, with about 4000 seconds per hour (really 3600), and
about 25 hours a day, there are about 100,000 seconds per day.

A 10 ppm (parts per million) error, would be about 1 second per day.
One course, then 20 ppm would be about 2 seconds per day.

I will need to check against a better “reference”, but I thought
that I got 30 seconds or a minute error in 12 hours, and
sometimes plus and sometimes minus… I will re-test.