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

RTC timer is shiffting after connection/disconnetion

Dear Nordic Devloper Zone,

I am facing a problem with RTC timer.

Here is a scenario :

I have an IOS application which is able to set the current time on the nRF51822.

In the nRF51822 application, I am using a timer on RTC1 (32kHz) which is triggered every seconds to manage time.

In the RTC1 timer interrupt, my application sends a notification to the connected device (IOS app) with the current time (posix format). This time is compared with the IOS app time and the difference must be obviously equal to 0.

It is always true when the device is connected to the device. I have tested during 1 day (connected non-stop), and the difference between nRF51822 time sent to the IOS app and the real time (from iPhone) is always 0.

But, each time a connection/disconnection occurred, the my RTC timer take 0.5 second late : the posix time sent to the IOS app has several seconds late depending on the number of connection/disconnection that I have done.

The RTC interrupt cannot be called to late and miss a second because the next event is planned in the interrupt itself. Therefore, if it is occurred, the interrupt will never be called.

void RTC1_IRQHandler(void)
{
    NRF_RTC1->CC[3] += TICKS_1_SEC;	
    //Some code here ....
}

It is like the RTC1 timer is in "pause" during the BLE connection.

Could you tell me if the RTC timer is stopped during BLE connections?

Best regards

Parents
  • Hi Sebastien,

    the RTC timer itself is not stopped when connecting/disconnecting, but interrupts can be delayed for a couple of ms due to SoftDevice radio interrupts when connected. This should not influence your timekeeping however, as the timescale is much larger than radio interrupts.

    I ran a test toggling an IO from the RTC1_IRQHandler while connecting/disconnecting, but I could not see similar behavior as you are describing. Are you sure you are not doing anything when connect/disconnect events happen? Maybe some other task is blocking the RTC1_IRQHandler from executing.

    rtc_ble_test.png

  • No problem :) I suggest you use toggle two different GPIOs, one in the interrupt handler and one using PPI. If the PPI-triggered GPIO toggles but the IRQ-triggered one does not toggle you know there is something delaying the IRQHandler

Reply Children
No Data
Related