Hi,
I have a problem with HCS12x microcontrollers.
Xgate code either run from RAM or the FLASH ( RAM is more preferrable as x gate runs only at half the speed of CPU ).
i came to know that at the startup.c, x gate code is copied from 'flash' to 'ram'.
Inorder to trace this two project files
1. with xgate in flash
2.with xgate in ram
I compared both the files i.e startup.c and datapage.c for both x gate in ram and x gate in flash . There is no single difference between the two....
i'm confused!!!.... howz the demarcation done between x gate in flash - > x gate ram in startup.c
help me out
What CW version are you using?
Difference is that some include file has smth like
#pragma CODE_SEG <RAM placement, other than predefined placement like DEFAULT_RAM>
It works even for S12 code. Just put your routine between
#pragma CODE_SEG <your RAM placement>
#pragma CODE_SEG DEFAULT
It will be copied to RAM by startup file.
Got more time...
In hivawe.h, when __XGATE__ is defined, you have this line for XGATE code:
#pragma CODE_SEG XGATE_CODE
This is the same for both cases, but prm files do differ when you choose RAM and when you choose FLASH.
XGATE_CODE placement may go to RAM segments and may go to flash segments.
You may control by hand placement of each function and XGATE vectors table.
1) to place function to flash add this line above function definition
#pragma CODE_SEG XGATE_CODE_FLASH
void myfoo(void){...
2) to place function to RAM add this above function
#pragma CODE_SEG XGATE_CODE_RAM
Please disregard suggestion to use #pragma CODE_SEG DEFAULT. You can't use it with XGATE, else you routine will be placed in wrong part of flash. To return to project default placement add this below the function.
#pragma CODE_SEG XGATE_CODE
So to force some XGATE function to RAM you put your function between these pragmas
#pragma CODE_SEG XGATE_CODE_RAM
foo()
{
}
#pragma CODE_SEG XGATE_CODE
And to force to flash
#pragma CODE_SEG XGATE_CODE_FLASH
foo()
{
}
#pragma CODE_SEG XGATE_CODE
You may also force XGATE vectors to flash or RAM. Placing it in flash will worse interrupt response times a bit, but you may save some RAM.
#pragma CONST_SEG XGATE_CONST_RAM
#pragma CONST_SEG XGATE_CONST_FLASH