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

Can the device reset without going through NVIC_SystemReset()?

Some situations like heavy ble activity causes the nrf52832 to restart without hitting breakpoints in the NVIC_SystemReset.

Assuming there aren't any hardware issues, is it possible for a device soft-reset without going through the core_cm4.h NVIC_SystemReset call?

  • Yes. A Hard Fault can escalate to Lockup, and this will trigger a reset by default on NRF5x. So you can try to implement a HardFault_Handler() function. Another reset source could be the watchdog (if enabled).

    Note that NVIC_SystemReset is declared static inline and thus you cannot simply put a breakpoint in there and expect it to be hit, as there will be one copy of this function for every call in your code. This might confuse the debugger.

  • Yes, and you can look at the reset registor.

    uint32_t reset_reason;
    sd_power_reset_reason_get(&reset_reason);
    

    Reset Sources

        RESET_RESETPIN = 0x1,
        RESET_DOG = 0x2,
        RESET_SREQ = 0x4,
        RESET_LOCKUP = 0x8,
        RESET_OFF = 0x10000,
        RESET_LPCOMP = 0x20000,
        RESET_DIF = 0x40000,
        RESET_NFC = 0x80000,
    
  • That's not really correct. By default a hardfault goes to the hardfault handler and by default that just spins forever. If you have defined in the Nordic hardfault handler then it logs a load of information and then jumps to a Hardfault_Process() method which, again by default, resets. But it does this by calling NVIC_SystemReset(). So the one path which does cause a hardfault to cause a reset is a specific SDK code path which does call via NVIV_SystemReset(), it's not 'reset by default on the NRF5x'.

    GDB is supposed to be able to insert breakpoints at all locations for static inlined functions, it's documented as such in the manual, but I'm cautious about those too. You can use a hardware breakpoint to catch writes to SCB->AIRCR however that's possibly too late anyway.

Related