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

Example to use app_timer for calendar on nRF52810

Hi

I have seen some queries for support asking if app_timer can be used for real time clock and calendar functionality,

i am using the nRF52810 but the answers were either for the nRF52832 suggesting to use RTC2 or

there was no real code shared showing, how it may be achieved.

nRF52810 has only RTC0 and RTC1, so i would like to know how to setup the app_timer for this purpose

as I am using the Soft device (S112) also for BLE operations.

I know that using app_timer_create() one can start a new timer, this time has to be running running when my device is put to

systemOn sleep mode and wakeps up periodically to capture some data from ADc and time stamp it, then send it to a phone

smart phone.

My accuracy requirement is only up to one minute resolution, it need not be accurate to the second.

Any suggestions to get me going would be greatly appreciated.

Parents
  • Hi Tesc,

    Apologies for the late response... :-)

    I have resolved the issue from my side after looking at all the queries and answers from the Nordic team. For the benefit of others who might be interested and facing similar issues, here is my solution description.

    My system needs a real time clock. However, having only one internal RTC clock source in the nRF52810, which is used by the soft device, i could not use this resource.

    I have created an app_timer() instance for the RTC, which interrupts every 60 seconds, this is mainly due to the fact that my application does not require time granularity in seconds, so i can also save some battery life by this infrequent wake up.

    The idle_state_handle() and sleep_mode_enter() function put the unit to sleep when there is no user or BLE activity underway for a while. I am using system ON sleep mode, where the RAM is fully operational. So every 60 seconds, the app_timer interrupt wakes up the device and updates the clock time. And a routine in the main loop updates the calendar - taking into account leap year and months with 30 or 31 days.

    So in sleep and operational modes, the app_timer keeps ticking and the RTC gets updated. The RTC value is compressed into two 32-bit integers - i am using year, month, date, weekday, hour, minutes ans seconds, each is one byte data.

    The user can wake up the unit from sleep by pressing a key, which is configured as a wake up key, via the GPIO sense input configuration function.

    I want to enable RAM retention for one small area of RAM where I store the RTC value, so that this value is never lost during reset time RAM initialization.

    I checked the literature for setting up RAM retention, but could not find a suitable and clear explanation. Can you please share the proper description for the nRF52810.?

    Regards

    Chary BS

  • Hi,

    Thanks for the update.

    Regarding the RAM retention, please create a new ticket for that. It is a very specific question, and only vaguely related to the question about calendar.

    Regards,
    Terje

Reply Children
No Data
Related