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

Is GPREGRET preserved across toggle of nRESET?

I'm trying to use gpreg for state across toggles of nRESET. I thought it was working, but when I tested it on hardware without jtag connected it seemed that gpreg was getting reset as well.

Before I go down the path of trying something else, should GPREGRET survive an external reset?

My hardware doesn't have any physical buttons and is glued shut. I'm concerned that during testing firmware builds on production hardware that I might push a some broken application firmware. Without working application firmware, you can't enter dfu mode. The one thing we do have is a reset button (wired to nRESET), so I'm using a range of gpreg values as a 'reboot counter'. Each time the bootloader starts (and the gpreg is <10) I add 1 to the gpreg. If the gpreg is < 10 && > 5, I automatically enter DFU mode. On the app side each time the watchdog timer is updated (from the main loop) I decrement the gpreg. So if you reset the device 6 times in a row (waiting few seconds between resets) it will automatically enter DFU mode.

On a possible related topic, it seems like RESETREAS often doesn't indicate that the WDT triggered the reset. My WDT_IRQHandler either triggers a breakpoint or just spins for the reset to occur. Sometimes when I reset back into the bootloader, POWER_RESETREAS_DOG is set and othertimes it isn't.

Parents
  • If you go to Power chapter and see "Reset Behaviour" section You will find that GPREGRET (retained registers) is only preserved for CPU lockup+Soft reset+Wakeup from SystemOFF.

    nReset is pin reset. So the register will be cleared. Why don't you just write to application registered flash area? they will stay there, use pstorage update to update the flash content. I know that it will be slow, but I think there is no better solution for you.

    Are you clearing the register bits of the RESETREAS after you check them. The only known anamoly for POWER->RESETREAS on latest nRF51 kits is 41. POWER RESETREAS register may erroneously indicate LOCKUP.

  • It would be nice if you come back with your test results. Seems like some hardware issue, but I think WDT is well tested peripheral and hope that it is some thing else related to software.

Reply Children
No Data
Related