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.

CCS/TMS320F28379D: how to switch section from Flash to RAM

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

I have used CCS 5 and now I am using CCS 9. I realized that the compiled code in CCS 9 has switch section now, but it did not generate switch section in CCS 5. I admit they were two different projects, but they both have used switch statement in c files.

I guess my question is two-fold:

1) was it a compiler setting that decided to generate switch section or not, or was it simply compiler version difference? CCS 5 uses compiler TI v6.x.x, while CCS 9 uses compiler TI 18.x.x or higher.

2) how to copy the switch section from flash to RAM so it runs a bit faster? I know how to set up to copy the code section (.text section) from flash to RAM in the link command file, but I can't find anywhere showing how to do the switch section.

Thanks a lot.

  • Hi,

    Here is the answer to your 2nd question:

    You will have to use the function memcpy() this will copy the section of the code defined in linker command file into RAM. Please refer C2000Ware examples along with Flash linker command file, which shows how to define .TI.ramfunc.

    I will have to check with our compiler team on your 1st question and revert back to you in 2-3 days.

    Regards,

    Nirav

  • Thanks for the quick reply. I understand .TI.ramfunc concept. User can specify LoadStart and RunStart in the cmd file, and then memcpy in a c code. Any code with .TI.ramfunc pragma will be handled that way. However how do you make .switch section to do the same? I can copy the the .switch to ram, but i'm afraid I have to somehow notify linker so it links to the new .switch section in ram, instead of flash. BTW, The function that uses switch statement is already in .TI.ramfunc. Thanks.

  • You are right, following the same way _ramfunc is defined, .switch is now in ram like below:

    .switch : {}
    LOAD = FLASHD,
    RUN = RAMLS01,
    LOAD_START(_SwitchLoadStart),
    LOAD_SIZE(_SwitchLoadSize),
    LOAD_END(_SwitchLoadEnd),
    RUN_START(_SwitchRunStart),
    RUN_SIZE(_SwitchRunSize),
    RUN_END(_SwitchRunEnd),
    PAGE = 0, ALIGN(8)

    Thank you so much. I appreciate if you answer my question #1. 

  • Nirav,

    I got the email reminder to mark this case, but before I do it, can you attempt to answer my second question about what compiler property decides to generate .switch section or not?

    Thanks,

    Jinhui

  • Jinhui,

    On your #1 question: I don't think it is related either to compiler setting or the compiler version.  It can be due to the difference in switch case density.  If you have more scattered case numbers in the switch statement (like cases 1, 8, 20, 35 instead of cases 1, 2, 3, 4), the compiler may not implement it using switch.  This might be the case with your CCS5 project.  Please check. 

    Thanks and regards,
    Vamsi

  • Vamsi,

    Both projects have the same style switch statement with continuous cases. I tried different optimization levels, the compiler 6.1.3 always does not produce the .switch section, while the new one 18.12.4 always does. At this point it is all about my curiosity, no big deal for my project anymore. It is just interesting...

    Thanks,

    Jinhui

  • Jinhui,

    Thank you for the update.  For this observation, hope you used the same project with both compilers.

    In general, compiler may or may not implement the switch.  It will try to implement the least expensive way (cycles).

    Compiler team might have made enhancements to handle switches better in the latest versions and hence implementing it in latest version.

    Thanks and regards,
    Vamsi

  • thank you very much. I'm good with your answers and appreciate them.