First, when you just copy two functions from flash to ram without further precautions, that might or might not work, it depends on the code.
Here's a short summary how you can write the code in C so it will work or not compile.
- First, don't let the compiler generate any runtime routine calls. Those don't get copied to RAM, and unless you can keep them accessible, calling them will crash.
Doing this will actually limit the part of the C language you can use, but the good news is that you do not have to guess, the compiler will not compile it, if it contains any runtime function references. For example if you start to divide longs the compiler tries to generate a call to a long division runtime, but will fail because of this pragma. If you use simple C code, you should be fine though. If someone later changes your code to use long divisions, it will fail at compile time, at least.
// before your code to be relocated
#pragma MESSAGE ERROR C3605 /* C3605: Runtime object '_SEXT16_32' is used at PC 0xa*/
- Next put all the functions which should end up in RAM into their own section.
#pragma CODE_SEG WHATEVER
void fun(void) {
// no long divisions here :smileywink:
}
.......
#pragma CODE_SEG DEFAULT
// disarm
#pragma MESSAGE DISABLE C3605 /* C3605: Runtime object '_SEXT16_32' is used at PC 0xa*/
- next in the prm, allocate one are in RAM and one in flash for your code
(or reuse some RAM if you know what you are doing

In the prm file:
ROM_IMAGE = READ_ONLY 0xF000 TO 0xF2FF RELOCATE_TO 0x0200;
...
PLACEMENT
...
WHATEVER INTO ROM_IMAGE;
What this will do is not to avoid to generate absolute references (JMP ext, JSR ext), but instead they will just jump to the right RAM address instead.
Note that I'm convinced that it does work this way, but I did not try it out. Therefore there might be many tipos in the snippets above.
A few links (asked google for RELOCATE_TO HC12)
Really look into this:
http://forums.freescale.com/attachments/freescale/CFCOMM/1592/1/tn228.pdfThe linker manual, you also have this one locally. Search for RELOCATE_TO.
http://www.freescale.com/files/soft_dev_tools/doc/ref_manual/CW_Build_Tools_Utilities_RM.pdfHope it helps (to cite CrazyCat)
Daniel