Variable initialization in EEPROM at Compile Time

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

Variable initialization in EEPROM at Compile Time

819 Views
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

Labels (1)
0 Kudos
2 Replies

289 Views
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 Kudos

289 Views
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 Kudos