This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nrf52 RAM Retention issue

Hi, In my project i would like to save 100 bytes of information in RAM before going to System-off sleep mode.I have tested the example project given in sdk11 works okay.Have used the same in my application as well.I am using softdevice S132 .Configured a button to wake up. My issue begins here :-( -After programming my board I used the push button to wake my device,the RAM data was available and works perfectly.But if I power cycle the board once,and after my device sleeps if I wake my device by pressing the push button the RAM details are not read.But what I noticed is the register GPREGRET was written to and read as expected.

-Should i take any special care while saving data to RAM?

  • Please let me know where is the VARIANCE_DATA_ADDRESS. Also please have a look at this link at the answer by NICK. You can follow what we do to configure NOLOAD section as in our DFU bootloader project in SDK v11.

  • #define VARIANCE_DATA_ADDRESS 0x2000F080 //0x20009000 cheers!!

  • Bui, I just ported the code into keil just the ram retention logic.What i observed was while in debug mode the ram retention works otherwise it does not.When I check the noint the code literally hangs up due to some clock registers being uninitialized.Attaching the main file for you reference. The hash defines used below are from the ram retention sample code.

  • // This pin is used for waking up from System OFF and is active low, enabling sense capabilities. nrf_gpio_cfg_sense_input(PIN_GPIO_WAKEUP, BUTTON_PULL, NRF_GPIO_PIN_SENSE_LOW); nrf_delay_ms(1);

    			 if ((NRF_POWER->GPREGRET >> 4) == RESET_MEMORY_TEST_BYTE)
    	{
    			// Take the loop_count value.
    		 
    			NRF_POWER->GPREGRET = 0;
    
    		
    		 // clear GPREGRET register before exit.
    		 NRF_POWER->GPREGRET = 0;
    					
    
    
    			if (*p_ram_test != RAM_MEMORY_TEST_WORD)
    			{
    					printf("Read Failed\r\n");
    			}
    			else{
    				 printf("Read Success\n");
    			}
    
    			*p_ram_test = 0;
    	}else{
    		printf("RESET\r\n");
    	}
    
    	// Write the known sequence + loop_count to the GPREGRET register.
    
    	NRF_POWER->GPREGRET = ((RESET_MEMORY_TEST_BYTE << 4));
    
    	// Write the known value to the known address in RAM, enable RAM retention, set System OFF, and wait
    	// for GPIO wakeup from external source.
    
    	//LEDS_ON(1 << READY_PIN_NUMBER);
    	nrf_delay_ms(1000);
    
    	// Switch on both RAM banks when in System OFF mode.
    	NRF_POWER->RAMON |= POWER_RAMON_ONRAM0_RAM0On << POWER_RAMON_ONRAM0_Pos
    		| POWER_RAMON_ONRAM1_RAM1On << POWER_RAMON_ONRAM1_Pos
    		| POWER_RAMON_OFFRAM0_RAM0On << POWER_RAMON_OFFRAM0_Pos
    		| POWER_RAMON_OFFRAM1_RAM1On << POWER_RAMON_OFFRAM1_Pos;
    
    	// Write test word to RAM memory.
    	*p_ram_test = RAM_MEMORY_TEST_WORD;
    		
    		 printf("\r\nSleep: \r\n");
    		  nrf_delay_ms(10);
    	// Enter System OFF and wait for wake up from GPIO detect signal.
    	NRF_POWER->SYSTEMOFF = 0x1;
    	// Use data synchronization barrier and a delay to ensure that no failure
    	// indication occurs before System OFF is actually entered.
    	__DSB();
    	__NOP();
    	printf("\r\nStart: \r\n");
    
  • #define RAM_MEMORY_TEST_ADDRESS (0x2000F000UL) /< Address in RAM where test word #define RAM_MEMORY_TEST_WORD (0xFEEDBEEFUL) /< Test word that is written to RAM address RAM_MEMORY_TEST_ADDRESS. */ #define RESET_MEMORY_TEST_BYTE (0x0DUL) /**< Known sequence written to a special register to check if this wake up is from System OFF. */

    #define MAX_TEST_ITERATIONS (1) /**< Maximum number of iterations this example will run. */ #define SUCCESS_OUTPUT_VALUE (0xAB)

Related