InBuilt RTC Implementation for nrf54l15 nordic MCU

My task is to implement inbuilt RTC for nordic MCU nrf54l15 series.

When i use the below API nrfx_grtc_init, it is throwing a error and returning a error code which is saying Zephyr already initialized GRTC internally.

is it true ? if not, how i can use the API for initialising the RTC , any other API we need to use?
provide inputs in going forward.



//Initialize GRTC
// nrfx_err_t err = nrfx_grtc_init(GRTC_IRQ_PRIORITY);
// if (err != NRFX_SUCCESS)
// {
// printk("nrfx_grtc_init() failed with code: %d\n", err);
// // prints NRFX_ERROR_ALREADY =195887116 error code
// // Zephyr already initialized GRTC internally
// return;
// }

Parents
  • Hi,

    May I ask what you will use the GRTC for? As you write, it is used by the Zephyr RTOS, and the typical way of using it is via Zephyr kernel timer APIs. Unless there is a need to use the GRTC directly, I advice against it.

    You cannot stop/start or change "global" configurations of the GRTC, as it is used by the system. In principle you can use available CC channels and interrupts as long as you don't touch anything used by the Zephyr kernel or MPSL, though. For MPSL it is documented that it used GRTC_3_IRQn for interrupt and GRTC channels 7 to 11 (so you cannot use the IRQ you have selected).

    From your code snippets I see you use interrupts and then I do not see major with using it that way instead of using Zephyr timer APIs (if you had a need to use it with PPI, that could have been different).

  • GRTC is used for synchronization b/w subsystems, wakeup events, timestamping events, low power operations, comparing channels. It provides global time base.

    I am trying to implement inbuilt RTC for nrf54l15 MCU, can you please provide inputs in implementing this?

    a.) can i use COUNTER api's to implement inbuilt RTC ?
    b.) Can i use nrfx APIs ?

    Suggest which way is better to proceed further on implementing inbuilt RTC ?

  • Hi,

    Using the GRTC directly is tricky, as it is "own" by the Zephyr kernel and the MPSL. With the use case you describe I do not see any benefits of using it directly instead of using normal Zephyr timerAPIs? Note that when you use this, the GRTC is used under the hood, and that is the recommended and supported way to use it.

  • I need to use inbuilt GRTC for calculating accurate UNIX timestamps(including DATE,TIME details).
    I shall use GRTC for calculating time in wake-up events even though the other peripherals are in sleep.

    For such similar purposes, i need to use GRTC.
    So, please provide inputs in implementing the inbuilt GRTC which includes configuring, initialising of GRTC and using it for user application purposes.

Reply Children
Related