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?

Parents
  • // 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");
    
Reply
  • // 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");
    
Children
No Data
Related