Sync RTC to GNSS time without large time step

Hi Nordic Dev team,

I'm using the older nRF SDK in a project that is built using a nRF52840.  I have an RTC and a GNSS connected to the nRF52840.  I use one of the LP timers internally to keep track of time as an internal RTC that can quickly be accessed in memory for time stamping my sensor values.  I'm looking for ways of keeping the RTC from drifting from GNSS time that doesn't create large time discontinuities (steps) in my sensor logs.  Do you have any examples of this that I can refer too?

Thanks,

Parents Reply
  • If using an interrupt to increment the timestamp you can do the same kind of adjustment as (say) temperature calibration. The trick is very slow adjustments as you note in the post.

        else if (NRF_RTC1->EVENTS_TICK == 1)
        {
            NRF_RTC1->EVENTS_TICK = 0;
    #if defined(V_AND_V_TEST_CODE)
            nrf_gpio_pin_toggle(TICK_EVENT_OUTPUT);
    #endif
            // 8Hz tick gives us 17 years operation using 32-bit unsigned timers
            // Coin cells are unlikely to last that long, maybe a year or more
            if (mAdjustTickCount < 0)
            {
               // Slow down, don't increment the 125mSec tick
               mAdjustTickCount++;
            }
            else if (mAdjustTickCount == 0)
            {
               // Spot on, usual situation
               mRTC_PacketSampleTimer++;
            }
            else
            {
               // Speed up
               mRTC_PacketSampleTimer+=2;
               mAdjustTickCount--;
            }
         }

Children
No Data
Related