* Codewarrior 6.1 for microcontrollers
* S08AW60
* PRM file:
SEGMENTS Z_RAM = READ_WRITE 0x0070 TO 0x00FF; RAM_A = READ_WRITE 0x0100 TO 0x025F; RAM_B = READ_WRITE 0x0260 TO 0x086F; ROM_A = READ_ONLY 0x1A00 TO 0x21FF; ROM_B = READ_ONLY 0x2200 TO 0xFFAF; ROM_C = READ_ONLY 0xFFC0 TO 0xFFCB; END PLACEMENT NVRAM INTO RAM_A; NVROM INTO ROM_A; DEFAULT_RAM INTO RAM_B; _PRESTART, ... DEFAULT_ROM INTO ROM_B; ...END
*C Source code:
unsigned char RAMVar1 @"NVRAM";unsigned char ROMVar1 @"NVROM"=0;unsigned char RAMVar2 @"NVRAM";unsigned char ROMVar2 @"NVROM"=245;...unsigned char RAMVar200 @"NVRAM";unsigned char ROMVar200 @"NVROM"=27;void InitNonVolatileVars(void){ unsigned char *pRAM; unsigned char *pROM; unsigned char n; n=__SEG_SIZE_NVRAM; pRAM=__SEG_START_NVRAM; pROM=__SEG_START_NVROM+LastCopyAddress(); do{*pRAM++=*pROM++;}while(--n);}void MyFunc(void) { RAMVar1=RAMVar2; ... }void SynchroRAM2ROM(void){...}
* Problem: ROMVars are not linked because they are not referenced in source code.
* Undesired solution: modify PRM file like this:
ENTRIES ROMVar1 ROMVar2 ... ROMVar200END
* Desired solution: modify source code like this:
unsigned char RAMVar1 @"NVRAM";__root unsigned char ROMVar1 @"NVROM"=0;unsigned char RAMVar2 @"NVRAM";__root unsigned char ROMVar2 @"NVROM"=245;...
I use "__root" for Atmel ATmega compiler, but I'd like the same code to run in Freescale's AW60:
#define __root __AlwaysLinkFreescale
How to do it?, is there a reserved word to tell the compiler and linker not to remove non referenced const vars?.
Thanks in advance