Execute Functions from RAM on LPCLink2 (LPC4370)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Execute Functions from RAM on LPCLink2 (LPC4370)

636 Views
QM
Contributor II

Hi NXP, 

This is the second post I am making on this topic, my previous post seems to be getting ignored so I am asking again. 

First the setup: Two Link2 boards working as a target/debugger for the LPC4370 chip.

Issue: Speed of execution of code (functions) from flash (too slow) compared with executing my code entirely from RAM.

I am trying to configure my MCUXpresso project to relocate all of my code from flash to RAM on startup, and execute it from RAM. I have followed the steps on page 213 of the MCUXpresso user guide "Relocating majority of an application into RAM." However, when I debug my code I see that the functions are still running from flash memory locations, even though my RAM is showing a large percentage of its memory filled after building my project. 

I have also tried using the macro __RAMFUNC(RAM) on my time critical functions, which does put those functions into RAM and speeds up my execution time during debug. However, when I reset the micro after debugging, those functions must once again get executed from flash as the execution speed slows down again.

I really need to work out why the steps in the MCUXpresso user guide are not working for me, or if I have some misconception about what I am trying to do. Can someone please help me with this problem. I have been trying to solve it for weeks now without any result. 

Thanks,

Regards, 

Quinn

0 Kudos
3 Replies

615 Views
QM
Contributor II
I think I may have solved my problem. I think what was happening was that the code was being copied to RAM from flash but my startup file was still calling the main that was in flash and not the newly copied one in RAM. To solve this I made a dummy main and called my real main real_main.c. So main is still called in flash but it then calls the real_main() 'function' that is in ram. For the record this is mentioned in some documentation (such as: https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Relocating-code-from-FLASH-to-RAM/m-p/473993) but only in the context of debugging. I think some other mention should be made about the cr_startup_lpc43xx.c file and how it calls the your main in flash even with the linkscripts folder method described in the MCUXpresso manual. Regards, Quinn
0 Kudos

624 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

"However, when I reset the micro after debugging, those functions must once again get executed from flash"

->> How do you know this?

 

BR

Alice

0 Kudos

621 Views
QM
Contributor II

I don't know this for sure, but I don't have any other explanation for the speed difference of my program when I debug and after I reset. And the slower execution speed is the same speed as when I don't use those macros on my functions (when debugging and after reset).  

Regards, 

Quinn

0 Kudos