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

nrf_drv_rtc_counter_clear(&rtc) issue

Hi,

I have a problem where I have to put a delay for 50 us after  nrf_drv_rtc_counter_clear(&rtc); to get 0 counter from nrf_drv_rtc_counter_get(&rtc);

seems that the clear task not happening immediately, how can I fix this to erase the delay after the clear counter function ?

Best Regards

Jawad

Parents
  • It's a consequence of using a slow 32.768kHz clock for the RTC when the system is using a much faster asynchronous clock. See nRF52832 Product Specification v1.4 section 25:

    CLEAR and STOP (and TRIGOVRFLW; not shown) will be delayed as long as it takes for the peripheral to clock a falling edge and rising of the LFCLK. This is between 15.2585 uSec and 45.7755 uSec (rounded to 15 uSec and 46 uSec for the remainder of the section).

    Table 46: RTC jitter magnitudes on tasks
                                    Task Delay
    CLEAR, STOP, START, TRIGOVRFLOW +15 to 46 ìs
    
    Table 47: RTC jitter magnitudes on events
    Operation/Function          Jitter
    START to COUNTER increment  +/- 15 ìs
    COMPARE to COMPARE          22 +/- 62.5 ns

    TRIGOCRFLW could be used instead, but there will still be uncertainty as noted above but at least an interrupt would be generated which can be used as a handshake:

       // OVRFLW is interrupt every RTC Counter overflow (if enabled)
       if (pRTC->EVENTS_OVRFLW == 1)
       {
          // 32.768kHz for 24-bit overflow with divisor set to 0 (ie /1) is 512 seconds
          pRTC->EVENTS_OVRFLW = 0;
          mRTC_JustOverflowed = true;
       }
    .

Reply
  • It's a consequence of using a slow 32.768kHz clock for the RTC when the system is using a much faster asynchronous clock. See nRF52832 Product Specification v1.4 section 25:

    CLEAR and STOP (and TRIGOVRFLW; not shown) will be delayed as long as it takes for the peripheral to clock a falling edge and rising of the LFCLK. This is between 15.2585 uSec and 45.7755 uSec (rounded to 15 uSec and 46 uSec for the remainder of the section).

    Table 46: RTC jitter magnitudes on tasks
                                    Task Delay
    CLEAR, STOP, START, TRIGOVRFLOW +15 to 46 ìs
    
    Table 47: RTC jitter magnitudes on events
    Operation/Function          Jitter
    START to COUNTER increment  +/- 15 ìs
    COMPARE to COMPARE          22 +/- 62.5 ns

    TRIGOCRFLW could be used instead, but there will still be uncertainty as noted above but at least an interrupt would be generated which can be used as a handshake:

       // OVRFLW is interrupt every RTC Counter overflow (if enabled)
       if (pRTC->EVENTS_OVRFLW == 1)
       {
          // 32.768kHz for 24-bit overflow with divisor set to 0 (ie /1) is 512 seconds
          pRTC->EVENTS_OVRFLW = 0;
          mRTC_JustOverflowed = true;
       }
    .

Children
No Data
Related