Zephyr RTC Alarm versus k_timer_start

Dear Customer Support,

Wanted to open a case to follow up on this old one Case ID: 335484  

 nRF52840 with Zephyr RTOS: How to use RTC with struct rtc_time? 

I initially looked at the counter alarm under

https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/drivers/counter/alarm/src

using rtc0 and counter_set_channel_alarm

Test environment nRF52840, but this seems to be pretty generic to any other nRF platform

I have few high level questions:

1-what would be the pros and cons of using the Zephyr counter alarm feature versus using the plain Zephyr k_timer_start with a registered callback?

2-with the counter alarm feature, there is an upper limitation on the alarm duration around 8 second, as obtained by

counter_get_top_value or counter_get_max_top_value

how to increase that maximum tick value to configure a higher duration value?

3-if we force the device into a power off state using sys_poweroff(), is there a possibility to wake up the device through an RTC callback

There is an available sample that shows how to wake up using a button press, so the idea is to replace the button by a RTC wake up

Thank you

Jamal

PS

I will have more follow up questions later...

Parents Reply
  • Hello,

    I have using example provided in the above link

    https://github.com/zephyrproject-rtos/zephyr/blob/main/tests/drivers/rtc/rtc_api/src/test_time.c

    I call the rtc_get_time

       int ret = rtc_get_time(counterDev, &timeGet);
       if (ret < 0)
       {
          LOG_ERR("Cannot read date time: %d", ret);
          return ret;
       }

       LOG_INF("RTC date and time: %d-%d-%d %d:%d:%d",
               timeGet.tm_year, timeGet.tm_mon, timeGet.tm_mday,
               timeGet.tm_hour, timeGet.tm_min, timeGet.tm_sec);

    right after initiating the RTC with

       struct rtc_time timeSet;
       time_t timeEpoch = 1738083814;

       gmtime_r(&timeEpoch, (struct tm *)(&timeSet));

       int ret = rtc_set_time(counterDev, &timeSet);
       if (ret < 0)
       {
          LOG_ERR("Failed to set time");
       }

    the rtc device is defined

    const struct device *counterDev = DEVICE_DT_GET(DT_NODE_LABEL(rtc0));

    Enabled rtc0 in my .dts file as

    &rtc0 {
       status = "okay";
    };

    To your question, the first log from rtc_get_time is

    RTC date and time: -1--1--1 -1:-1:-1

    subsequent calls to rtc_get_time return the same log

    RTC date and time: 0-117617--1 -1:204237:536874088

    Question back:

    are you able to run this example on a nrRF52840 based devKit?

    Also,

    could you please be more thorough addressing my other questions?

    Thank you

Children
No Data
Related