Is it possible to write GPREGRET when S210 is running? Writing directly to register causing HardFault.
Is it possible to write GPREGRET when S210 is running? Writing directly to register causing HardFault.
Hi,
Using the S210 stack, this is unfortunately not possible. There is no API call to get/set this register.
What are you trying to use this register for? If you power on the RAM while going into sleep, you can retain your variables when awoken.
BR Håkon
I must remember program status in case reset occurs. Can I do it in RAM?
BR PW
Hi,
Due to the RESETREAS register is PAN'ed in the current revision of the device, you must workaround this by powering on the RAM (since GPREGRET is unavailable in S210).
Use the sd_power_ramon_set API call:
/**@brief Sets bits in the NRF_POWER->RAMON register.
*
* @param[in] ramon Contains the bits needed to be set in the NRF_POWER->RAMON register.
*
* @return ::NRF_SUCCESS
*/
uint32_t SVCALL(SD_POWER_RAMON_SET) sd_power_ramon_set(uint32_t ramon);
This call is directly mapped 1:1 on how you would set the RAMON register. If you set one variable declared within the area of RAM block 1, you can use this for checking wakeup source: static uint8_t reset_reason_from_systemoff attribute((at(0x20001000)));
Set this before going into systemoff, and do a check when waking up again.
Best regards Håkon
I don't use poweroff. What about RAM content when random reset occurs? Can I read unchanged variable when I use power_ramon function earlier (etc. at the beginning of the program) .
Best regards PW
Hi,
I've misread your application.
If you want to store variables after reset, you must store the variable to flash. There's an example on this in our SDK, which is called "flashwrite_example".
GPREGRET register will be cleared after reset. Same with RAM.
Best regards Håkon