This just happened to me with a QG8
turns out it was my PRM file settings, which I'd been messing around with in order to write to flash - if you don't set your program to start execution at the right point (VECTOR 0 _Startup), ie the spot where you've told the linker to stick the program data into flash, then it will never get to the code you have which sets up your ICS registers. And it doesn't know what to do and flies all over the place.
Here's a copy of my PRM file:
/* This is a linker parameter file for the mc9s08qg8 */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. */ Z_RAM = READ_WRITE 0x0060 TO 0x00FF; RAM = READ_WRITE 0x0100 TO 0x01FF; MY_RAM = READ_WRITE 0x0200 TO 0x025F; F_ROM = READ_ONLY 0xE000 TO 0xE05F RELOCATE_TO 0x0200; ROM = READ_ONLY 0xE060 TO 0xFFCF; /* INTVECTS = READ_ONLY 0xFFD0 TO 0xFFFF; Reserved for Interrupt Vectors */ENDPLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */ DEFAULT_RAM INTO RAM; //non zero-page variables FlashRAM INTO F_ROM; //Flash Write routine _PRESTART, /* startup code */ STARTUP, /* startup data structures */ ROM_VAR, /* constant variables */ STRINGS, /* string literals */ VIRTUAL_TABLE_SEGMENT, /* C++ virtual table segment */ DEFAULT_ROM, COPY INTO ROM;/* copy down information: how to initialize variables */ _DATA_ZEROPAGE, /* zero page variables */ MY_ZEROPAGE INTO Z_RAM;ENDSTACKSIZE 0x50VECTOR 0 _Startup /* Reset vector: this is the default entry point for an application. */
Hope this helps somebody