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

Unpredictable behaviour of RTC2 on nRF24le1

I found a problem using the RTC2 on the nRF24le1 which i dont know how to solve it.

I am using the RTC2 on the master to generate a TICK interrupt exactly every 1s. With the formula on page 97, i set the compare register RTC2CMP1:RTC2CMP1 to 7FFE which should generate interrupts exactly every 1s. But the behaviour is in two points different as expected.

  1. The RTC2 generates interrupts 3-6 ms earlier, so the interval is like 0,996869s which corresponds to 7F98 and not 7FFE.

  2. The interval decreases every second one RTC2 tick (like 7F97, 7F96, 7F95, ...). Is this a bug?

How can i solve this, especially the point 2.? I need a constant interval.

Regards

Parents
  • Hi Ewan

    For a high level of accuracy you need an external crystal oscillator. The internal ones are highly inaccurate, and can only be used when you don't care much about the accuracy.

    Without an external 32kHz crystal the only option is to synthesize the LF clock from the high frequency crystal, which you can select by writing 0x02 to the CLKLFCTRL register. Please keep in mind that this will keep the external HF crystal running at all times, which will increase the current consumption significantly.

    I am able to get your code running, and I see a 1 second toggle when selecting the right clock source. The only change I made to the code was to add a GPIO toggle in the interrupt, to be able to measure the interrupt timing accurately.

    I have not been able to reproduce your second issue, where you see the interval change over time. Are you still experiencing this issue?

    Best regards
    Torbjørn

Reply
  • Hi Ewan

    For a high level of accuracy you need an external crystal oscillator. The internal ones are highly inaccurate, and can only be used when you don't care much about the accuracy.

    Without an external 32kHz crystal the only option is to synthesize the LF clock from the high frequency crystal, which you can select by writing 0x02 to the CLKLFCTRL register. Please keep in mind that this will keep the external HF crystal running at all times, which will increase the current consumption significantly.

    I am able to get your code running, and I see a 1 second toggle when selecting the right clock source. The only change I made to the code was to add a GPIO toggle in the interrupt, to be able to measure the interrupt timing accurately.

    I have not been able to reproduce your second issue, where you see the interval change over time. Are you still experiencing this issue?

    Best regards
    Torbjørn

Children
  • Hi Torbjørn,

    i have changed the behaviour of the master and the slaves depending of your infos.

    The master does not need power down mode, because it is waiting for connections, so i used the synthsized clock which is very accurate for me (differs in 1-3 micro seconds).

    For the slaves i am using the standby mode at the moment (instead of the register retention) simulating a power down mode, until i will add a external 32kHz crystal. I think it is not possible to avoid using an external 32kHz crystal or an external RTC module. Soldering an external 32kHz crystal i think is the best method.

    Thanks and Regards Ewan

  • Hi Ewan

    This sounds like a good strategy. Adding an external 32k crystal (and the two load caps) should not be too expensive, and allows you to get both low current consumption and accurate timing.

Related