I have a project where I need to store some data in the flash memory of the HCS08GT60. My project has a hardware calibration routine that stores calibration data into variables. Then I copy the variables into variables that I have assigned addresses to in flash memory. All of my code is in C using CodeWarrior. My code compiles and appears to work, but the variables in flash memory get reset when I cycle the power to the MCU. I am not sure why these variables get reset. I want the flash variables to survive a power reset.
Here is some of my C code:
#pragma DATA_SEG NON_INITIALISED
unsigned short FlashThrottleMin;
unsigned short FlashThrottleNeutral;
unsigned short FlashThrottleMax;
#pragma DATA_SEG DEFAULT
That code is immediately after all of the include lines but before any other variable declarations. I also have code that sanity checks those values to see if they were set already by the hardware calibration routine and code that copies those varialbes into RAM variables during startup.
Here is the code in P&E_ICD_linker.prm and monitor_linker.prm, but not P&E_FCS_linker.prm.
/* This is a linker parameter file for the GT60 */
NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */
SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
FlashThrottleMin = NO_INIT 0x1EFF TO 0x1F00;
FlashThrottleNeutral = NO_INIT 0x1F01 TO 0x1F02;
FlashThrottleMax = NO_INIT 0x1F03 TO 0x1F04;
//ROM = READ_ONLY 0x182C TO 0xFFAF;
Z_RAM = READ_WRITE 0x0080 TO 0x00FF;
RAM = READ_WRITE 0x0100 TO 0x107F;
ROM1 = READ_ONLY 0x1080 TO 0x17FF;
ROM2 = READ_ONLY 0xFFC0 TO 0xFFCB;
END
PLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */
NON_INITIALISED INTO FlashThrottleMin;
NON_INITIALISED INTO FlashThrottleNeutral;
NON_INITIALISED INTO FlashThrottleMax;
DEFAULT_RAM INTO RAM;
_DATA_ZEROPAGE, MY_ZEROPAGE INTO Z_RAM;
DEFAULT_ROM, ROM_VAR, STRINGS INTO ROM; /*,ROM1,ROM2*/ /* in case you want to use ROM1,ROM2 here as well, add option -OnB=b to the compiler. */
END
STACKSIZE 0x50
VECTOR 0 _Startup /* Reset vector: this is the default entry point for a C/C++ application. */
//VECTOR 0 Entry /* Reset vector: this is the default entry point for an Assembly application. */
//INIT Entry /* For assembly applications: that this is as well the initialization entry point */
Does anybody have any ideas as to why this is not working as expected? Thanks.