non-volatile Variables - HOW??

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

non-volatile Variables - HOW??

1,361 次查看
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

标签 (1)
0 项奖励
3 回复数

427 次查看
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 项奖励

427 次查看
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 项奖励

427 次查看
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 项奖励