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

RTC Registers state after soft reset and OTA.

Hardware Description:

MKBN02A00 module based on nRF52832 SOC

Software Description 

nRF SDK 15.2.0 , SoftDevice S112

Application

I'm logging sensor data in external flash memory with the timestamp. I used RTC2 to count time in the application. The module is battery powered.

Whenever I perform softreset  or OTA, and later try to read RTC2 COUNTER and capture/compare 0 registers (without initializing RTC again), The value is 0 for both the registers. And therefore I lose track of time.

Question:

I wanted to know if the RTC register value is reset during Softreset and OTA process.

And also if there is any other solution to keep track of time on nRF52832.

Parents
  • Hello,

    The RTC is a peripheral, and unfortunately, all the peripherals are reset on all reset reasons, even soft resets, as you can see here. This means that you will reset the counter whenever you reset the nRF52832. (OTA triggers several soft resets).

    If you want to retain the value, you can try to write it to RAM, which is never actively reset (but may reset if the nRF reset was caused by a power out or brown out). But remember that before you start up again, the RTC will not be running, so you may loose some time every time you reset. You also need to consider how often you want to copy the counter register to RAM. every minute? Every second? More often?

    The last option is to save the time in flash, which requires you to do flash operation every time you want to save the time. This will of course cost some power, and it is fairly slow (compared to ram, or the register itself). Perhaps an external battery driven RTC (Real time clock), and not the Real time counter that is present on the nRF is what you need, in order to keep track of time between resets and power outs.

    BR,

    Edvin

Reply
  • Hello,

    The RTC is a peripheral, and unfortunately, all the peripherals are reset on all reset reasons, even soft resets, as you can see here. This means that you will reset the counter whenever you reset the nRF52832. (OTA triggers several soft resets).

    If you want to retain the value, you can try to write it to RAM, which is never actively reset (but may reset if the nRF reset was caused by a power out or brown out). But remember that before you start up again, the RTC will not be running, so you may loose some time every time you reset. You also need to consider how often you want to copy the counter register to RAM. every minute? Every second? More often?

    The last option is to save the time in flash, which requires you to do flash operation every time you want to save the time. This will of course cost some power, and it is fairly slow (compared to ram, or the register itself). Perhaps an external battery driven RTC (Real time clock), and not the Real time counter that is present on the nRF is what you need, in order to keep track of time between resets and power outs.

    BR,

    Edvin

Children
Related