nrf54l15-dk rtc

Hi,Team,

I'm currently using the nrf54l15-dk. I want to set the rtc of the nrf54l15-dk to obtain the timestamp. How should I configure the rtc? Which examples should I refer to?
My ncs version is v2.8.0.

Thanks.

Parents
  • Hello,

    You can use UNIX timestamp (using Date time+ k_uptme_get. UNIX timestamp requires that the data time library has obtained a valid time first (e.g., via data_time_update_async or data_time_set), then coverts uptime UNIX time. source: date_time groupdate_time.h

    In the prj.conf file you need to set the following config to enable GRTC SYSCOUNTER :

    # Ensure GRTC SYSCOUNTER is started by the driver on boot (nRF54L15)
    CONFIG_NRF_GRTC_START_SYSCOUNTER=y

     Now in the app code, you can follow the following steps:

    a. Initializing Date Time library and setting valid time

    1. Initialize Date Time library and set valid time. source ( [date_time API; date_time.h])
    1. Converting uptime to UNIX time (ms) when you need a timestamp
    • After time is valid: int64_t ts = k_uptime_get(); date_time_uptime_to_unix_time_ms(&ts); // ts now holds UNIX time in milliseconds This API specifically converts a k_uptime_get() value to UNIX time using the maintained offset. [date_time.h; date_time group]

    An example code

    int64_t uptime = k_uptime_get();
    date_time_uptime_to_unix_time_ms(&uptime);
    
    // At this point `uptime` contains the unix timestamp in milliseconds.

Reply
  • Hello,

    You can use UNIX timestamp (using Date time+ k_uptme_get. UNIX timestamp requires that the data time library has obtained a valid time first (e.g., via data_time_update_async or data_time_set), then coverts uptime UNIX time. source: date_time groupdate_time.h

    In the prj.conf file you need to set the following config to enable GRTC SYSCOUNTER :

    # Ensure GRTC SYSCOUNTER is started by the driver on boot (nRF54L15)
    CONFIG_NRF_GRTC_START_SYSCOUNTER=y

     Now in the app code, you can follow the following steps:

    a. Initializing Date Time library and setting valid time

    1. Initialize Date Time library and set valid time. source ( [date_time API; date_time.h])
    1. Converting uptime to UNIX time (ms) when you need a timestamp
    • After time is valid: int64_t ts = k_uptime_get(); date_time_uptime_to_unix_time_ms(&ts); // ts now holds UNIX time in milliseconds This API specifically converts a k_uptime_get() value to UNIX time using the maintained offset. [date_time.h; date_time group]

    An example code

    int64_t uptime = k_uptime_get();
    date_time_uptime_to_unix_time_ms(&uptime);
    
    // At this point `uptime` contains the unix timestamp in milliseconds.

Children
Related