Hello Ban,
It's simple to separate areas of code using the linker and the #pragma command... here's how it works:
in the linker you can create and seperate different segments:
SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
APPCODE = READ_ONLY 0xC000 TO 0xEFFF;
BOOT = READ_ONLY 0xF000 TO 0xFF2F;
END
//and then you select what code is placed where:
PLACEMENT
DEFAULT_ROM, ROM_VAR, STRINGS INTO APPCODE;
BOOTCODE INTO BOOT;
END
once this is set, code will be placed by default into the appcode area, but anything that you want to be placed into the boot code should have this before the function:
#pragma CODE_SEG BOOTCODE
void function(void){}
and once you want to return to the app code, return it to the default value:
#pragma CODE_SEG DEFAULT
This same principle also applies for RAM(DATA_SEG) and constants(CONST_SEG)
fleik