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

RAM retention issue

Hi,

I am using NRF52832 with softdevice s112 and SDK 15.3. I have 20 bytes of data which I want to retain in RAM during system off. I use the following code so that the data is not initialized.

uint8_t m_addl_adv_manuf_data[ADV_ADDL_MANUF_DATA_LEN] __attribute__ ((section(".noinit")));

Then in main, I get the slave and section and set the ram retention on. I checked the value and my variable belongs in slave 1 section 0 and I set the power to 0x1FFFF. But the value is not retained after wakeup from system off

uint32_t p_offset = (uint32_t)(&m_addl_adv_manuf_data[0] - RAM_START_ADDRESS);
uint8_t ram_slave_n = (p_offset / 8192);
uint8_t ram_section_n = (p_offset % 8192)/4096;
NRF_LOG_INFO(" addr %x offset %x RAM section %d, slave %d",&m_addl_adv_manuf_data[0],p_offset,ram_slave_n,ram_section_n);
sd_power_ram_power_set(ram_slave_n,(1 << ram_section_n) << POWER_RAMON_OFFRAM0_Pos);
uint32_t ram_power;
sd_power_ram_power_get(ram_slave_n,&ram_power);
NRF_LOG_INFO("power %x",ram_power);

On the other hand, If I assign the variable m_addl_adv_manuf_data to some other slave and section (slave 4 and section 0) 0x20008000 by using the sample code then even if I do not enable the RAM retention in the power register, it is still able to retain the value. This is really confusing. Can you explain why ?


#define RAM_MEMORY_TEST_ADDRESS (0x20008000UL)

Thanks,

Jyoti

  • Hi Jyoti,

    Jyoti said:
    But I do have the Segger RTT Viewer open to look at the log. Does that mean the program is running in debug interface mode?

    Yes, RTT goes through the debug interface.

    Jyoti said:
    Also, I have evaluation version of keil, so I think scatter file will not work

    That's correct. You can't edit the scatter file in the lite version. This is why I didn't use the scatter file in the example I sent you. 

    For IAR it shouldn't be necessary to create a new linker section. You can try to define your variable like this:

    __no_init uint8_t m_addl_adv_manuf_data[ADV_ADDL_MANUF_DATA_LEN] @ <RAM address> ; (IAR doc)
    Or if you chose to use Segger embedded Studio:
    uint8_t m_addl_adv_manuf_data[ADV_ADDL_MANUF_DATA_LEN]  __attribute__((section(".non_init")));
Related