* 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
Hello FordFairlane,
I assume you don't want to use PRM file solution "ENTRIES" due to fact you would add all the ROMVars defined in it, right?
What about disable Smart Linking for the module that defines ROMVars only e.g.:
.PRM:
-------
ENTRIES
main.c.o:*
or you can separate all the ROMVar definitions in separate module e.g. "ROMVars.C" & "ROMVars.h" and then you can avoid Smart Linking for the ROMVars only.
.PRM:
-------
ENTRIES
ROMVars.c.o:*
END
Stanish
Thank you stanish, your solution is better than mine, but this is not what I'm looking for. I have a lot of non volatile variables defined in a lot of C files, I'd like not to modify all of them because it takes too much time and I'd like to use the same source code for Freescale and Atmel.
Thank you