AnsweredAssumed Answered

Moving a Function to, then Executing from RAM (Kinetis)

Question asked by nicholasf on Jun 3, 2014

After reading AN4329, I attempted to implement the relocation of a function to internal RAM, but cannot get the compiler to do it.[1]  The only difference between my program and the example is that the "funcInRAM" is located in a different '.c' file, and I believe this is causing the problem.  I have read through some other discussions on this forum which discuss other problems, but not this one.[2][3][4][5]

 

The problem is visible in the xMAP, which shows that "my_ram" (where the function should have been relocated to) is empty.

 

# .my_ram

#>2000C000          ___myRAMStart (linker command file)

#>2000C000          ___myRAMEnd (linker command file)

#>00000000          ___CodeSize (linker command file)

 

The main loop calls the 'funcInRAM()' repeatedly in an infinite loop, and the 'funcInRAM' is defined as follows in a separate file:

 

 

#pragma define_section mySectionInRAM ".myCodeInRAM" far_absolute RX

#pragma section mySectionInRAM begin

 

void funcInRAM(void){

...

}

#pragma section mySectionInRAM end

 

 

I have attached my LCF to this post.

 

I appreciate any help, as I am quite stuck on this.

 

[1] http://cache.freescale.com/files/soft_dev_tools/doc/app_note/AN4329.pdf

[2] relocating code

[3]relocating code from FLASH to RAM

[4]Re: How to relocate memory library function using #pragma?

[5] How to Copy Function from Flash to RAM & execute it

Original Attachment has been moved to: MK20FX512_flash.lcf.zip

Outcomes