K_Timer and RTC Integration

We are using the nRF5340 with Zephyr OS v3.6.99-100befc70c74 and nRF Connect SDK v2.7.0-5cb85570ca43. We have the following questions:

  1. Is our understanding correct that the K_Timer utilizes the RTC and operates in the interrupt handler mode of the RTC?

  2. What is the tick duration when using the K_Timer with RTC?

    when,
    CONFIG_TICKLESS_CAPABLE=y
    CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32768
    CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768
    CONFIG_SOC_NRF53_RTC_PRETICK=y
    CONFIG_SOC_NRF53_RTC_PRETICK_IPC_CH_FROM_NET=10
    CONFIG_SOC_NRF53_RTC_PRETICK_IPC_CH_TO_NET=11
  3. Is there a mechanism to generate a software timer that counts the delay without running in the interrupt handler?

Parents
  • Hi,

    Is our understanding correct that the K_Timer utilizes the RTC and operates in the interrupt handler mode of the RTC?

    Yes, Zephyr uses an RTC intance for keeping track of time. The kernel handles the interrupts though, and if you use APIs like k_sleep, or delayed work queue itims etc this the applicaiton processing happens in thread mode.

    What is the tick duration when using the K_Timer with RTC?

    Here, you have CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32768 which is default, and is the highest resolution you can have as the RTC runs of the 32.768 kHz clock. This gives a tick duration of 1/32768 Hz = 30.5 us.

    Is there a mechanism to generate a software timer that counts the delay without running in the interrupt handler?

    Zephyr provide several APIs based on the RTC, and in most cases several are suitable and you need to choose. See Kernel Timing for an overview. There are also conseptcs like delated work queues, you can use dedicated threads that sleep with k_sleep, etc.

Reply
  • Hi,

    Is our understanding correct that the K_Timer utilizes the RTC and operates in the interrupt handler mode of the RTC?

    Yes, Zephyr uses an RTC intance for keeping track of time. The kernel handles the interrupts though, and if you use APIs like k_sleep, or delayed work queue itims etc this the applicaiton processing happens in thread mode.

    What is the tick duration when using the K_Timer with RTC?

    Here, you have CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32768 which is default, and is the highest resolution you can have as the RTC runs of the 32.768 kHz clock. This gives a tick duration of 1/32768 Hz = 30.5 us.

    Is there a mechanism to generate a software timer that counts the delay without running in the interrupt handler?

    Zephyr provide several APIs based on the RTC, and in most cases several are suitable and you need to choose. See Kernel Timing for an overview. There are also conseptcs like delated work queues, you can use dedicated threads that sleep with k_sleep, etc.

Children
No Data
Related