S12ZVM prm address mapping

cancel
Showing results for 
Search instead for 
Did you mean: 

S12ZVM prm address mapping

191 Views
keanchen
Contributor II

I want to put the const variable in the designated ram section, and the initial value in the designated ROM section,It will be stored in COPYDOWN SECTION by default,

like this:

RAM_MyRam @ 0x001000

ROM_MyRom @ 0xFC0000

#pragma CONST_SEG RAM_MyRam

const uint16 MyRamtestvar = 7000;

#pragma CONST_SEG DEFAULT

I want to store the initial value 7000 of MyRamtestvar in ROM_MyRom segment .

How to map the initial value of RAM_MyRam segment to ROM_MyRom?

 

0 Kudos
2 Replies

172 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

This is possible but it changes placement of all other constants used in DopyDown function because in the prm file is :

COPY INTO ROM;

The COPY is keyword for project processing.

 

In your case I would split flash and create my own Segment/Placement. Then I would use a new part of flash for my constants. Finally, I would use own routine to initialize RAM variables.

 

Moreover, there are two ways of data placement into flash.

1) The new space is created into the prm file and then variables are placed into this space

//original  ROM = READ_ONLY 0xFE0000 TO 0xFFFDFF;

// adjusted

ROM = READ_ONLY 0xFE1000 TO 0xFFFDFF;

MY_DATA_ROM = READ_ONLY 0xFE0000 TO 0xFF0FFF;

...

...

MY_DATA_ROM INTO MY_DATA_ROM ;

 

In the code:

 

#pragma CONST_SEG MY_DATA_ROM   // MY_DATA_ROM is "MY" extra segment created in the prm file

  const unsigned int xxx;

#pragma CONST_SEG DEFAULT

The variables are placed into this segment by compiler.(Usually from lowest address of crated space)

#pragma CONST_SEG MY_DATA_ROM

 

2) A part of flash is removed from compiler visibility. For example:

//original  ROM = READ_ONLY 0xFE0000 TO 0xFFFDFF;

// adjusted

ROM = READ_ONLY 0xFE1000 TO 0xFFFDFF;

...

....

Then in the code you can initialize variable:

const __far xxx[] @ 0xFE0000 = { 1,2,3,4,};

 

I hope I have not made a mistake.

 

Best regards,

Ladislav

0 Kudos

166 Views
keanchen
Contributor II

Hi Ladislav:

Thank you for your answer, but I want to put the variable in RAM because I need to calibrate it online. I want to put the initial value in the designated ROM. Copy to RAM during initialization. My current practice is like this
#pragma DATA_SEG MY_RAM_SEC
uint16 MyRamTest0;
uint16 MyRamTest1;
uint16 MyRamTest2;
#pragma DATA_SEG DEFAULT

#pragma CONST_SEG MY_ROM_SEC
const uint16 MyRomTest0 = 7000;
const uint16 MyRomTest1 = 7000;
const uint16 MyRomTest2 = 7000;
#pragma CONST_SEG DEFAULT

When initializing, I copy all the values of MY_ROM_SEC segment to MY_RAM_SEC,
Do you have a better suggestion?

0 Kudos