AnsweredAssumed Answered

Place variable at Absolute Address within a Segment

Question asked by sebasira on Mar 21, 2013
Latest reply on Mar 25, 2013 by sebasira

Hi all!

 

I'm using CW v4.6 with HCS12...

 

I have a segment definition as (I only put what matters):

 

SEGMENTS

    PAGE_EEPROM = NO_INIT  0x0400 TO 0x0FFF;

END


PLACEMENT

    EEPROM_DATA_PAGE  INTO  PAGE_EEPROM;

END


Normally, I define a 32bits EEPROM variable as:


#pragma CONST_SEG EEPROM_DATA_PAGE

  const dword EEPROM_VARS1;

#pragma CONST_SEG DEFAULT

 

But as my project grows and so does those variables, the compiler place them wherever it wants, as long as they remain inside 0x0400 - 0x0FFF.

Now I want them to be at a fixed location so they "stay on the same place" with different firmware revisions.

 

What I did was:

 

#pragma CONST_SEG EEPROM_DATA_PAGE

  const dword EEPROM_VARS1 @0x400;

#pragma CONST_SEG DEFAULT

 

Then, looking at the .map I can see that:

 

EEPROM_VARS2                              2000       4       4       4   EEPROM_DATA_PAGE

EEPROM_VARS1                              2004       4       4       3   .abs_section_2004

 

Why EEPROM_VARS1 isn't in EEPROM_DATA_PAGE? I mean, it phisically is there, but when I want to check where is each variable this doesn't help me

 

Maybe I should do the declaration other way.

 

Thanks!

 

 

 

 

Outcomes