This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Changing RTC2 compare values on nRF24LE1 during runtime

Hi,

i am working with nRF24LE1's as one master and many slaves. I also use the RTC2 functionality for the register retention mode.

As i read in the documentation the RTC2 counts from zero up to the specified compare value (RTC2CMP0:RTC2CMP1) and when using the compare mode 11 an interrupt is assigned and the counter is reseted.

Is the following be possible:

  1. Stop running RTC2
  2. Changing the compare value (increasing or decreasing)
  3. Starting the RTC2 again but with not reseting the current RTC2 counter (continuing)?

I does not find any infos about it in the documnetation.

Regards

  • Hi Ewan,

    Unfortunately, it's not possible to pause or stop the RTC on the nRF24LE1. You can only disable the RTC but that will clear the timer val.

    A workaround is to capture the value of the timer right just before you stop it. And then you can do a calculation to adjust the next compare value when you start it again to compensate. And after the timer hit the compare for the first time, you can switch back to the original compare.

  • Hi Hung Bui,

    this is my current workaround but i hoped there is a simple and faster solution. Ok.

    What would happen if i change the compare values without stopping the RTC (ensuring the current counter is not near the compare value)? Is the new set compare value automatically used or has it to be reloaded with stopt-start of the RTC?

  • You can change the RTC compare without stop-start the RTC. But as you mentioned, care should be taken so that glitch won't happen. We mentioned in the spec:

    The RTC2 compare value is updated every time RTC2CMP1 or RTC2CMP0 is written. This might give unwanted behavior if precaution is not taken when updating any of the variables. When new values are written to RTC2CMP1 and RTC2CMP0, the RTC2 IRQ should be disabled to prevent unwanted RTC2 IRQ.

  • This behaviour is exaclty what i wanted but have overlooked in the spec. :-(

    Thx for your help.

Related