S12ZVM prm address mapping

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

S12ZVM prm address mapping

986 次查看
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 项奖励
回复
2 回复数

967 次查看
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 项奖励
回复

961 次查看
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 项奖励
回复