non-volatile Variables - HOW??

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

non-volatile Variables - HOW??

1,350 Views
toebsen
Contributor I

hi there

we have a problem storing variables in the flash of our S12XE100, we do not have any idea how we could achieve it. So Im asking, is there any easy way to save variables non-volatile, like a loader instruction or so? Do we really  have to implement the complex way with formating and Emulated EEPROM and stuff? Can you please show us some easy to implement way, perhabs with some code snippets?

Thanks for your time

 

Regards 

toebsen

Labels (1)
0 Kudos
3 Replies

416 Views
jsmcortina
Contributor III

Yes, you need to use emulated EEPROM or come up with an erase/programme scheme for Dflash. Also be aware of what will happen if the power is shut off during a write cycle.

 

James

0 Kudos

416 Views
Lundin
Senior Contributor IV
That is only necessary if you want to change the values in runtime. Perhaps the original poster can clarify if that is required by the application or not.
0 Kudos

416 Views
Lundin
Senior Contributor IV
Make a memory segment in the .PRM file, then write

#pragma CONST_SEG name_of_segment

const int variable;

#pragma CONST_SEG DEFAULT

Obviously the variables have to be const. I always declare them at file scope too, or the compiler might put them on the stack instead of nvm.
0 Kudos