Variable initialization in EEPROM at Compile Time

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

Variable initialization in EEPROM at Compile Time

889 次查看
belskyc
Contributor III

Hello,

 

I'm a user of the 8-bit HCS08 microprocessors (in this project I'm using the HCS08DZ60A).  Does anyone know of a technique where I can initialize a variable that's declared in EEPROM at compile time?  In other words, I'd like to do something like the following:

 

#pragma DATA_SEG    _EEPROM
// Variable initialized during compile. 
volatile unsigned char eeprom_byte = 0xAB;

 

So that after programming the microprocessor, the variable eeprom_byte is initialized to value 0xAB. 

 

What I'm trying to accomplish is a method for detecting a 'virgin load' of the firmware into the micro, and store the status in this byte. 

 

Thanks much,

~Chris

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

359 次查看
ok2ucx
Contributor IV

Chris,

 

looks like that accidentally the same question has already been answered in the following thread: http://forums.freescale.com/freescale/board/message?board.id=8BITCOMM&thread.id=15738

 

Hope this helps you, 

 

Pavel

0 项奖励
回复

359 次查看
CompilerGuru
NXP Employee
NXP Employee

Note that the key is that the segment used in the prm file must be using the READ_ONLY type,

not that the variable is const. I would actually make the variable const as the varible is not writable with a simple write, but as far as the tools are concerned they do not insist.

Everything in a READ_ONLY segment gets programmed at download time, everything in a READ_WRITE segment gets initialized during program startup (and everything in a NO_INIT or PAGED segment does not get initialized automatically at all).

 

Daniel

0 项奖励
回复