This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Oscillator Drift Compensation

Hi,

  I am trying to use the oscillator drift compensation to adjust the RTC 1 second interrupt to the gps 1PPS.  I am starting a timer when the GPS 1PPS occurs and then stop the timer when the RTC interrupts.  I was taking the compensation difference and then writing those values to the compensation registers.  I then wrote the time to be 59 min and 58 sec knowing that the RTC updates the compensation once an hour.  Is this a correct way of doing this because its not responding as i would expect. 

Thanks,

Will

  • Will,

    Which device is this for? In my understanding PPS is an output pulse from the GPS module.

    Regards,

    Sunil Kamath

  • Hi Sunil,

      I am trying to sync the RTC with a GPS 1PPS.  WHat I have done is when I get the 1PPS interrupt from the GPS, I start the RTC.  I have a RTC interrupt once a second that sends a GPIO high.  The GPIO is set low whe the 1PPS interrupt occurs.  What I have seen is that every second that passes, the RTC interrupt drifts by about 10us.  I can't explain why this is.

    Will

  • Will,

    RTC compensation registers are used to account for the oscillator drift from the 32KHz crystal driving the RTC. So the discrepancy you are seeing between the 1sec duration of the highly-acurate PPS and the RTC on the C6748 is normal.

    You would need to convert the 10us/sec drift into a per hour count value that the RTC will use to adjust the update cycle every hour. In this case it could be:

    60*60*10u = 36ms drift per hour. Converted to a count that would be 32.768K*36m = 1179.6 or 1180 or 0x49C.

    Drift that results in slower RTC will then need compensation_reg = 0x49C and drift that results in faster RTC will need the 2's complement in the compensation_reg = 0xFFFF FB64.

    In an end system, you could start the RTC on one PPS interrupt and stop it after a pre-determined number of PPS interrupts (60 for a 1 minute period). Assuming latencies are the same in both cases, you can get an estimate of the drift per minute by reading the RTC registers and compute the compensation as above.

    Please refer to section "Oscillator Drift Compensation" in the TRM (spru79) for more information. Hope this helps.

    Regards,

    Sunil Kamath

  • Hi Sunil,

      What causes the RTC drift?  Is there any way to stop the drift?  We really need usec coherency.  Would an external RTC perform just as badly?

    Will

  • Will,

    Usually the external reference clocks (in this case the 32KHz crystal) are susceptible to temperature, voltage, mechanical variations causing a drift in frequency - it is not really just an RTC issue. I suppose the main requirement here is the usec coherency. An external RTC might be the way to go - please check devices offered here.

    Regards,

    Sunil Kamath