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

NRF_POWER->GPREGRET

Hi Folks,

I am trying to get some data to persist past a reboot.  I noticed the ram_retention_pca1004 example  and it showed a simple assignment of:

NRF_POWER->GPREGRET = X

but when I do the following assignment (even before the reboot):

temp = NRF_POWER->GPREGRET;

temp is always 0.  (Needless to say the value is also zero after the power reset via watchdog timeout.)

I noticed in the example the following code:

#if defined(NRF52832_XXAA) || defined(NRF51422) || defined(NRF51822)
NRF_POWER->RAMON |= (POWER_RAMON_OFFRAM0_RAM0On << POWER_RAMON_OFFRAM0_Pos) |
(POWER_RAMON_OFFRAM1_RAM1On << POWER_RAMON_OFFRAM1_Pos);

Adding that didn't help, but I didn't expect it to as long as my assignment above keeps failing.

Is there a flag that needs to be set to use NRF_POWER->GPREGRET?

(I looked at using sd_power_gpregret_set but couldn't find the correct library to include, is that the correct solution?)

thanks, 
Bob

(Sorry for the basic question, just need some data to persist after a WDT reset.)

Parents Reply
  • What is the connection between no-init and PREGRET?

    I have the following code for testing:

    void NVRAM_Test(void)
    {
       uint32_t err_code;
       uint32_t gpregret_val = 0x00; 

       sd_power_gpregret_get(0, &gpregret_val);
       if(gpregret_val == 0xED){
            err_code = sd_power_gpregret_set(0, 0x00);
            APP_ERROR_CHECK(err_code);
       }
       else
       {
           err_code = sd_power_gpregret_set(0, 0xED);
           APP_ERROR_CHECK(err_code);
       }
    }

    When compiling I get:

    undefined reference to `sd_power_gpregret_get'
    undefined reference to `sd_power_gpregret_set'

    thanks again for the help,

    Bob

Children
Related