This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28386D: how to tell if code section is in ram or flash

Part Number: TMS320F28386D


Hello, I've create a FLASH_CMD linker file. At the end I have this.

.TI.ramfunc : {} LOAD = FLASH1 | FLASH4,
   RUN = RAMGS0 | RAMGS1 | RAMGS2 | RAMGS3 | RAMGS4 | RAMGS5 | RAMGS6
   etc...

What I think this means, is during Device_Init, the FLASH sections listed after LOAD will be memcpy'd to the RAM sections listed after RUN. So as long as I have my .text in FLASH1 or FLASH4, it will be copied to RAM and run from there. Is that correct?

In code I have:

#pragma CODE_SECTION(motor1ControlISR, ".TI.ramfunc");

I can see from the MAP file, this function is in the RAM section. But all other functions are in the FLASH section. If I was correct above, I shouldn't need this #pragma at all. But if that's the case, how can I tell if my functions are running from RAM or FLASH?

Do I still need this #pragma for all functions I want in RAM?

thanks

Ken

  • Hi Ken,

    By default all code goes to ".text" section.

    .TI.ramfunc : {} LOAD = FLASH1 | FLASH4,
       RUN = RAMGS0 | RAMGS1 | RAMGS2 | RAMGS3 | RAMGS4 | RAMGS5 | RAMGS6

    The above part of linker file says that the ".TI.ramfunc" section is to be run from RAM, and load from FLASH.
    It says nothing about where the functions code goes by default.

    The #pragma CODE_SECTION() is used to indicate that this particular function is to be put in the specified section (and if the RUN section is specified - copied from FLASH to RAM at program initialization). And this has to be done separately for each function.

    There is a special compiler option "--ramfunc=on" (you can find it under "C2000 Compiler -> Advanced Options -> Runtime Model Options), and when it is set, then ALL functions are run from RAM (that is ".TI.ramfunc" section). If your code fits in RAM then you can use it. Other than that, you have to choose which functions are to be run from RAM with the  #pragma CODE_SECTION().

    Best regards,
    Andy