Hi MCF52233,
See below a simple example of how this could be achieved:
lcf file:
---------
MEMORY
{
...
internal_flash: org = 0x00002000, len = 0x001FD000
internal_ram: org = 0x40000000, len = 0x00009000
my_ram_code: org = 0x40009000, len = 0x00001000 // <-- custom memory segment for custome code executed from RAM
...
}
SECTIONS
{
...
GROUP : {
.__uninitialized_intc_handlertable ALIGN(0x10) : {}
.data : {}
.sdata : {}
.sbss : {}
.sdata2 : {}
.sbss2 : {}
.bss : {}
} > internal_ram
.my_ram_code (VLECODE) :{} > my_ram_code // <-- place all .my_ram_code section VLE code into custom memory segment.
// Remove (VLECODE) if you do not use VLE
...
}
main.c
----------
#pragma push // save current pragma context
#pragma section code_type ".my_ram_code" ".my_ram_code" code_mode=far_abs
// function prototypes below should be placed into .my_ram_code section far absolute address mode
void test(void); // declare prototype
#pragma pop //restore original pragma context
void test(void)
{
asm(nop);
}
int main(void) {
volatile int i = 0;
test();
}
The startup automatically copies-down the appropriate function(s) into RAM. The ROM image generation must be enabled (default setting for the "Internal_flash" build target if project is generated by the Wizard).
You can check the .map file to see where the functions are placed...see the example snippet below:
...
.my_ram_code section layout
Starting Virtual File
address Size address offset
---------------------------------
00000000 000006 4003b000 00002808 1 .my_ram_code main.o
00000000 000006 4003b000 00002808 2 test main.o
...
Memory map:
Starting Size File ROM RAM Buffer S-Record
address Offset Address Address Line
...
.bss 40000548 0000000c 00002808 00031808 00031808 0
.my_ram_code 4003b000 00000008 00002808 00031808 00031808 239
Where 0x4003b000 is the address in RAM and 0x31808 is the address in ROM which is copied by the startup to RAM.
I hope it will help you.
Stanish