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

Real Time Clock and calender Implementation

Hi,

 Considering  https://devzone.nordicsemi.com/f/nordic-q-a/29013/best-way-to-implement-system-clock-on-nrf51 as reference and some other similar posts.I could reach to a point of understanding that inorder to implement Real Time Clock it requires Real Time Counter,app_timer and Timer.But unable to get exact way of implementation.Expecting your guidance regarding any example present related to nRF52 so that my implementation of Real Time Clock and Calender get easier.

And my other query is,if there is a requirement like implementing RTC so that, when device is turned on current time is displayed on Led Driver.But if device has to be in system off state for longer duration ,then there might be a situation after getting device turned on it displays some improper time.Please let me know what are the ways to reset it to current time? or what are the ways to always keep track of current time and display proper time whenever turned on?

Note:In my application softdevice is also used.

Thank you.

Parents
  • Hi,

    There is no SDK example implementing a calendar, but you can keep track of time using the app_timer as you write. This way you do not need an extra RTC instance, and the average accuracy will be identical to the accuracy of your LF crystal. The nRF specific implementation is quite easy. The simplest would be to use a repeated app_timer instance that wakes up every second, and update the real-time calendar data and display at that point (assuming it shows seconds). If it updates less frequently, you could, for instance, make the RTC wake the system every minute and update the display and real-time calendar data then.

    There is no way to keep track of time with an nRF when in system off mode. By definition, there are no clocks running in system off mode. If you need that, then you need to use an external RTC device. However, you can, of course, device a scheme were after reset the display will not show the time (or show an error of some sort, until the time has been set). If you are making a BLE device, then the obvious way to et time is via BLE.

    Smartphones implement a current time service, so you could include a current time service client on the nRF that retrieves the current time from the smartphone and sets the internal calendar accordingly.

  • how can i include a current time service client to retrieve date and time can i merge this with nrf calendar example ??

  • Hi,

    You can refer to the Current Time Application example. which implements a current time service client. You can take this as a reference and combine with the nrf calendar example, but you need to modify the example a bit to work properly with a SoftDevice. It probably makes more sense to use it for inspiration and copy in what you need, and for instance use the app_timer library to generate regular ticks instead of using an RTC directly.

  • can u also tell me how can i get millioseonds using nrf calendar ??

Reply Children
Related