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

Any way to put system into "OFF" state in hard fault handler with SD enabled?

Long title, but basically sums it up - is there any way to put the nRF51 into the off state from within the hard-fault handler if the soft-device was enabled prior to the fault? The complication is that the soft-device seems to protect the NRF_POWER peripheral, and when you're inside the hard-fault handler, you can't use sd_power_system_off() nor can you just access NRF_POWER->SYSTEMOFF. So it seems I'm somewhat stuck.

Any ideas on how I might be able to get around this?

The goal is to put the system into the off state to disable the WDT, in case it was running - I don't want the actual WDT reset to occur since technically, it's not guaranteed to preserve RAM through the reset (many of the other reset sources preserve RAM, but for whatever reason, the WDT does not). I've observed that RAM is usually preserved, but since it's not in the datasheet, I don't want to rely on it.

Thanks!

Parents
  • Unfortunately, not really... this was for production code, so I couldn't just clear UICRs, halt, or use the UART. I ultimately had to set things to generate an interrupt on WDT, quickly preserve some state in shared RAM between bootloader and application, issue a softreset, and then in the bootloader I check if the WDT is running or not, and if it is, I put the system into OFF and have it wake immediately back up using a GPIO-detect on a signal with a guaranteed state. It's not pretty, but it ensures I will always have a clean system on restart, and that shared RAM is preserved through all resets except power-on and pin-reset.

Reply
  • Unfortunately, not really... this was for production code, so I couldn't just clear UICRs, halt, or use the UART. I ultimately had to set things to generate an interrupt on WDT, quickly preserve some state in shared RAM between bootloader and application, issue a softreset, and then in the bootloader I check if the WDT is running or not, and if it is, I put the system into OFF and have it wake immediately back up using a GPIO-detect on a signal with a guaranteed state. It's not pretty, but it ensures I will always have a clean system on restart, and that shared RAM is preserved through all resets except power-on and pin-reset.

Children
No Data
Related