how to declare non-initialized variables (MPC5567)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to declare non-initialized variables (MPC5567)

Jump to solution
563 Views
Oliv74
Contributor I

Hello,

 

In my current project, I'm using a non-volatile battery backed SRAM, and now, I would like to declare variables that will be placed in that memory but that will not be initialized to zero at init.

In my lcf I added a memory section like that:

 

MEMORY{...    saved_ram:          org = 0x20000000,   len = 0x00020000...}SECTIONS{GROUP : {       .dataSavedRam  : {}    } >}

 and in my code:

 

#pragma push#pragma section data_type ".dataSavedRam" ".dataSavedRam"#pragma pop__declspec(section ".dataSavedRam") int savedVarExample;

But during startup my variable is initialized to 0 in the function __init_data (in __start.c).

 

So, what is the best solution to avoid that?

 

thank you.

Labels (1)
0 Kudos
1 Solution
312 Views
CrasyCat
Specialist III

Hello

 

In fact you need to modify the function init_data.

 

Look for FAQ-27500 on www.freescale.com. This should provide you some insight on how to implement that.

 

CrasyCat

View solution in original post

0 Kudos
2 Replies
313 Views
CrasyCat
Specialist III

Hello

 

In fact you need to modify the function init_data.

 

Look for FAQ-27500 on www.freescale.com. This should provide you some insight on how to implement that.

 

CrasyCat

0 Kudos
312 Views
Oliv74
Contributor I

Hello,

 

Thank you, it works fine now.

0 Kudos