Hi,
I am trying to set up a calibration protocol (XCP over CAN) on my controller (9S12DP256B).
To be able to modify parameter data online I need a section in RAM which contains all Parameters. At system startup this RAM section must be initialized with a Section in ROM containing the same data and the same mapping. The values in the ROM section are initialized either at compile time with the init-Values used in code or with the values from the last calibration session stored from the RAM to the ROM section after reception of a special XCP-Message.
My question: How can I tell the linker to map the parameters into RAM but having the same parameters (at a location with constant offset) stored in ROM?
I tried to map the parameters to RAM and use the automatic generated .copy section but there are some problems:
* the .copy section is optimized, e.g. parameters intialized to 0 in code are not member of the .copy section
* inside the copy section there are some other variables used to init RAM-Variables
-> the whole mapping of the parameters inside the .copy section is different to the RAM section
sample Code to create/initialize parameter:
#pragma DATA_SEG CALIBRATION_CONST
const volatile unsigned char SWITCH_TEST = 1;
#pragma DATA_SEG DEFAULT
sample prm-file:
...
SECTIONS
/* internal RAM */
CAL_RAM = READ_WRITE 0x3C00 TO 0x3CFF;
...
/* unbanked FLASH ROM */
ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF;
ROM_C000 = READ_ONLY 0xC040 TO 0xEF6F;
...
END
PLACEMENT
_PRESTART, STARTUP,
ROM_VAR, STRINGS,
VIRTUAL_TABLE_SEGMENT,
NON_BANKED, COPY INTO ROM_C000, ROM_4000;
DEFAULT_RAM INTO RAM;
CALIBRATION_CONST INTO CAL_RAM;
END
STACKSIZE 0x300
Thanks for your help!