AnsweredAssumed Answered

How to preserve variables from initialization after VLLS3

Question asked by Diego Colombo on Apr 18, 2014
Latest reply on Jun 26, 2015 by Matias Ferrari

Hi

I'm using a Kinetis KL05 with CW 10.5 ,

from the datasheet,SRAM content should be retained during VLLS3 stop mode.

Needing to compare with a variable value as it was before VLLS3 this variable  should not be initialized

 

I read that there is more than a way to do it:

https://community.freescale.com/thread/311175

tweaking the asm_start.c file or by mean of linkerdirectives in ProcessorExpert.ld

 

I tried unsuccessfully in this way,  my_n_data is the SRAM area that i want to preserve by initialization,just 4 bytes

MEMORY {
  m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000000C0
  m_text      (RX) : ORIGIN = 0x00000410, LENGTH = 0x00007BF0
  m_data      (RW) : ORIGIN = 0x1FFFFC00, LENGTH = 0x0000FFC /*  1000 */  
  my_n_data (RW) : ORIGIN = 0x20000BFC, LENGTH = 0x000004
  m_cfmprotrom  (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
}

/* Define output sections */
SECTIONS
{
  /* placing my named section at given address: */
  .my_block1 0x20000BFC :
  {
    KEEP(*(.n_data)) /* keep my variable even if not referenced */
  } > my_n_data
}

and in a c file

unsigned char  __attribute__((section (".n_data")))val_accel_old;

 

I don't write nothing in the .data and .bss sections,because i dont want my variable be  initialized from Flash value or filled with 0x00, is it correct or should i write something?

 

 

before entering in VLLS3 mode i write a known value in val_accel_old,say 0x25

 

at reset i verify that it comes from VLLS3 mode wake up,but the variable is initialized everytime at the same  nonsense value(0xB3).

 

Can you please explain me the right way to do the trick??

 

thanks

Diego

Outcomes