Hello everyone, I am using SPC584B70E5 microcontroller and I am trying to retain values from SRAM after waking up from Standby Mode. I am using an 8k SRAM which is always powered on (as specified in Reference Manual).
Here is what I've done:
When my microcontrollers receives a sleep request from CAN, it goes on StandbyMode as shown below:
- Fisrt I disable CAN peripherals:
can_lld_stop(&CANDRIVER1);
can_lld_stop(&CANDRIVER2);
- Then I disable clock and interrupts:
SPC5_PIT0_DISABLE_CLOCK();
SPC5_CAN_SUB_0_M_CAN_1_DISABLE_CLOCK();
......
irqIsrDisable();
- Finally it enters in STANDBY_MODE:
if(SPCSetRunMode(SPC5_RUNMODE_STANDBY0) == CLOCK_FAILED)
{
SPC5_CLOCK_FAILURE_HOOK()
}
It wakes up when I apply a 5V on wake_up pin.
Before doing all this procedure, I have already written some data to internal SRAM.
Now when my microcontrollers wakes up, all SRAM's data are lost.
I have tried two methods:
1) I modified the linker's file as shown, in order to reserve 4 bytes for my new backupsram :
MEMORY
{
....
ram : org = 0X400A8004, len = 192k - 64k
backupram : org = 0x400A8000, len = 0x04
.....
}
//define size, start, end ( for example __backupram_end__ = ORIGIN(backupram) + LENGTH(backupram);
SECTIONS
{
......
.standbyram: ALIGN(16) SUBALIGN(16)
{
__standbyram_start__ = .;
*(.standbyram)
*(.standbyram.*)
__standbyram_end__ = .;
} > backupram
.......
}
2) I changed the same ld file but this time I tried with ".noinit" attribute:
MEMORY
{
......
NOINIT org: = 0xXXXXXX , len= 0xXXX
.....
}
SECTIONS
{
...
.noinit (NOLOAD):
{
/* place all symbols in input sections that start with .noinit */
KEEP(*(*.noinit*))
} > NOINIT
...
}
__attribute__((section(".noinit"))) volatile uint32_t var;
None of them seems to work. Could someone suggest me some tips in order to make it work.
Thanks in advance
