If the NRF52833 is soft reset, can I read the value of the last recorded RTC counter?

Hi, please forgive my awkward English sentences.

Situation: A soft reset occurred while measuring calendar time.

Purpose: I want to know when the soft reset occurred.
[The purpose is to estimate the time when the reset occurred]
[The purpose is not to estimate the current time].

Question: When a reset occurs, does the value in the last count register of the RTC stay the same? Or does it get reset?

(If it is retained, is it possible to read the value stored in the RTC's count register?)

Thanks for reading.

  • I understand what you mean.
    Thanks for the good suggestions.

    However, I have tried logging everywhere NVIC_SystemReset() is present in my code, but the log output when reset occurs does not work anywhere.

    I would like to share my development environment and experimental conditions to see if there is a problem.

    -------------------------------------------------------------------------------------
    Development environment:
    I have configured my project based on the (ble_app_buttonless_dfu) example in (SDK17.1) of NRF52833.

    Reset behavior:
    Reset from programmer v3.0.3 of nRF_Connect for desktop.

    ---------------------------------------------------------------------------------------
    Result:
    - Confirmed that ram was not cleared and .noninit works.
    - After reset, output log with (sd_power_reset_reason_get) value 0x04 (=reset detected in soft reset).

    --------------------------------------------------------------------------------------
    questions:
    1) Is nRF_Programmer an inappropriate way to cause an artificial soft-reset?
    2) Can I get an explanation of the part about modifying NVIC_SystemReset() itself?
    When a reset occurs, I don't know where NVIC_SystemReset() comes into play.

    Thanks for reading.

  • Hi,

    I think there was a misunderstanding. Have you been using nRF Programmer to "soft reset" the device, all this time?

    When I talked about soft resets, I meant ones triggered by the device itself, through code. For example code that you added yourself, or some error handling code somewhere. I thought you wanted to find out at what time an error triggered a soft reset.

    Does that answer question 2?

    nRF Programmer will soft reset your device by directly accessing a hardware register - probably the RESET register in CTRL-AP, or perhaps the SYSRESETREQ bit in AIRCR (the register that NVIC_SystemReset writes to). See soft reset. This means that no code get's executed before reset. The device itself doesn't know when it will reset, it just suddenly happens!

    So, regarding 1: Using nRF Programmer is not appropriate if you want to try storing the RTC to flash. You can't trigger the reset externally. it would have to follow some execution path on the device itself, so you can add a flash write operation.

    It should be okay to use nRF Programmer if you are testing the .noinit RAM method.

    However, since you mention you're using a BLE sample, I realise that writing to flash is actually not a good idea. If the SoftDevice is enabled, soft resets should normally be done through SD_NVIC_SystemReset, which you can't modify. Also, the SoftDevice might trigger SD_NVIC_SystemReset by itself, and you won't have the chance to write the RTC to flash at all.

    So it's great that .noinit RAM works for you. This is your only option.

    Best regards,

    Raoul

  • Hello again, Mr. Raul.

    All answers have been completed.
    I was able to learn a lot about it.

    In the meantime, thank you for being so kind to answer our many questions.

Related