Hello
I am trying to figure out the ram retention on my nRF52-DK using SES and SDK v17.1.0. I've run through the example ram_retention, and studied a topic in Nordic's documentation, as well as a couple of threads here in DevZone, like this one, and this one. I adapted my code to implement RAM retention using the given examples, but it didn't work for me.
I did all the mentioned steps:
- declared the variable I want to retain in the .non_init section (
static uint32_t ble_activate __attribute__((section(".non_init"))); ) - turned the RAM powered on during the SystemOFF sleepmode:
// Configure the RAM retention parameters uint8_t i; for(i = 0; i < 8; i++) // Retain RAM 0 - RAM 7 { sd_power_ram_power_set(i, (POWER_RAM_POWER_S0POWER_On << POWER_RAM_POWER_S0POWER_Pos) | (POWER_RAM_POWER_S1POWER_On << POWER_RAM_POWER_S1POWER_Pos) | (POWER_RAM_POWER_S0RETENTION_On << POWER_RAM_POWER_S0RETENTION_Pos) | (POWER_RAM_POWER_S1RETENTION_On << POWER_RAM_POWER_S1RETENTION_Pos)); } // Delay for one second nrf_delay_ms(1000); - And checking up the NRF_POWER->GPREGRET for a pre-set value upon every wakeup.
However, I see that value is not preserved since I am outputting it using printf and it returns back as a nonsense number. Please, find my main.c attached. The crucial steps are implemented in void mers_ram_retention(void). The code is loosely based on ble_app_uart example, that is, in configures BLE stack as per original method and then starts advertising, and finally, goes to SystemOFF.

Could you please tell me what went wrong?
Best,
W


