Hi Gaurav Banyal,
Ok, I also have test it on the SDK_2.0_FRDM-KL03Z\boards\frdmkl03z\demo_apps\power_mode_switch code, you need do some modifications.
Now, let's take the MDK project as an example.
Modification points:
1. define the determined SRAM area for your according variable in the .scatter file like this:
#define m_data_size (0x00000700 - m_interrupts_ram_size) /*0x00000800*/
LR_m_text m_interrupts_start m_text_start+m_text_size-m_interrupts_start { ; load region size_region
VECTOR_ROM m_interrupts_start m_interrupts_size { ; load address = execution address
* (RESET,+FIRST)
}
ER_m_flash_config m_flash_config_start FIXED m_flash_config_size { ; load address = execution address
* (FlashConfig)
}
ER_m_text m_text_start m_text_size { ; load address = execution address
* (InRoot$Sections)
.ANY (+RO)
}
#if (defined(__ram_vector_table__))
VECTOR_RAM m_interrupts_ram_start EMPTY m_interrupts_ram_size {
}
#else
VECTOR_RAM m_interrupts_start EMPTY 0 {
}
#endif
RW_m_data m_data_start m_data_size-Stack_Size-Heap_Size { ; RW data
.ANY (+RW +ZI)
}
ARM_LIB_HEAP +0 EMPTY Heap_Size { ; Heap region growing up
}
ARM_LIB_STACK m_data_start+m_data_size EMPTY -Stack_Size { ; Stack region growing down
}
MYRAM 0x20000500 UNINIT 0x00000100{
.ANY (NO_INIT)
}
}
Define the sram address 0x2000500, the leghth is 0X100 as the your own ram, and don't initialize it after reset.
This step is very important.
2. define a variable in the range of mysram
char mycode __attribute__((at(0x20000500)));
After the above 2 steps, after you modify the mycode data, and enter VLLS3, then wake up by SW2 button, you will find the data retains.
in my example, before enter vlls3, I set mycode to 0x55, I have attached my code, in power_mode_switch.c line 297.
After test, I read mycode, it turns out 0x55.
So, the data really retains.
I also attached the scatter file for your reference.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------