This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to deal with a long time's Clock drift?

Hi,

I use to the nrf51422 with nordic's dev/ev kit.I want to build a project and the purpose is to get the sensor's date and use the ant protocol to deliver the date to another chip every 5 hours.The rest of the time the chip will go to sleep.But recently I test two board's clock drift,I find the clock will drift 1s every 10min.And my test is simple,I use the way: while(1) {
nrf_gpio_pin_set(Pin); nrf_delay_ms(1000); nrf_gpio_pin_clear(Pin); nrf_delay_ms(1000); } I don't know is there any solution can solve this problem? Thanks!

  • What about the power-consumption when using the application timer? Isn't the usage of the application timer bound to a higher sleep level?

    Does application timer not have any jitter? So the accuracy would be the accuracy of the RTC clock source?

  • Hi Mike

    When RTC is used directly, you can have it trigger a task of another peripheral on the nRF51 pretty much instantly when using PPI channels.

    When you use RTC directly with a RTC interrupt handler, it will typically take 3-4 us from the RTC event trigger until code execution starts in the interrupt handler. This is of course depending on if there is no interrupt with the same or higher priority already utilizing the CPU.

    For the application timers, they will work pretty much the same in this regard as when using RTC directly with interrupt handler. There is a little more overhead when using the applicaiton timer, so the delay should be a little longer from RTC event until the application timer handler starts to execute, but it should not be many microseconds in addition to the RTC interrupt handler.

    You should test execution delay however with compiler optimization enabled. Enable compiler optimization in order for your application to be executed in as few instructions as possible. This will make the code execute faster and finish sooner and will therefore save power. To enable compiler optimization in Keil, select Options for Target -> C/C++ tab and set Optimization to “Level 3” and check “Optimize for Time”. In order for you to efficiently debug the application code in Keil, the setting should be however Optimization: “Level 0” and “Optimize for Time” should be unchecked.

    Since using an application timer will possibly add a few microseconds to the CPU usage compared to using RTC directly, it will add something to the current consumption. However, if the frequency of timer events is only a few Hertz, it is so small it can normally be neglected, in the order of nanoamps.

    Application timers are operational in System On low power mode. This is the mode the BLE softdevice uses in between radio events in order to save power. If the device enters System Off low power mode however, neiter application timers or RTC will be operational.

Related