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/TMS320F28023: Put jump table in FLASH on page 0

Part Number: TMS320F28023

Tool/software: Code Composer Studio

Win7 (SP1), CCS 6.

I am making a program with a "Function Jump Table," and I am having difficulty getting the table to be placed in the program section (.text) in page 0.

My program receives an ASCII byte in the range '0'..'Z' from the serial port then depending on that byte I want to jump to 43 different functions.

Ideally, I'd like it to put the table in the .text section someplace. The actual location is unimportant.

This is what I have so far, and this works...

Here is the partial contents of Menu_Commands.def

/* 0 */   GetParagraphs,
/* 1 */   GetDirect,
/* 2 */   PutDirect,
/* 3 */    ...(40 more)

And the declaration to the corresponding FunctionCallTable looks like...

#pragma DATA_SECTION(FunctionCallTable, "FunctCodeTbl");
static void (* FunctionCallTable[])(void) = {
#include "Menu_Commands.def" /* see above */
};

And finally, the code that actually jumps...

if ((byte1 >= '0') && (byte1 <= 'Z')) {
    byte1 -= '0';
    FunctionCallTable[byte1]();
}

I created a memory area in FLASH in page 1, then I make a section (you see above) and that works, but the problem is the compiler or linker creates a bunch of entries in the .cinit section because it thinks it is data that needs to be initialized. Not to mention all the effort of setting aside some FLASH so the two memory areas don't overlap.

So, I have tried to replace the pragma with the following...

#pragma CODE_SECTION(FunctionCallTable, ".text");

but I get a compiler error stating...
"N:/Standalone/Piccolo-28022/Src/MainSub.c", line 81: warning #1111-D: pragma CODE_SECTION can only be applied to a function definition, not "FunctionCallTable" (declared at line 83)

Please, can someone tell me how to set this straight?

I have considered writing all this in assembler, and I am sure I can do so, but I'd rather let the C compiler deal with it.

There is an additional issue I am having, this probably warrants a separate thread, but it is loosely related.

I am getting a linker error...

<Linking>
"N:/Standalone/Piccolo-28022/CMD/_Standalone(general).CMND", line 301: error #10099-D: program will not fit into available memory.  run placement with alignment/blocking fails for section "FunctCodeTbl" size 0x56 page 1.  Available memory ranges:
   F_FUNTABL    size: 0x60         unused: 0x60         max hole: 0x60      

As you can see, the amount needed is 0x56, and the hole is 0x60. I haven't figured this out yet either.

Thanks for any help on this,
Mark

  • Hi,

    ***CODE***_SECTION, so no wonder you get complaint about using this pragma with data. Array of pointers to functions is still data, not functions. Use #pragma DATA_SECTION instead. I'm using DATA_SECTION to place some constants in custom area.

    Edward
  • I presume you want FunctionCallTable to be directly programmed into FLASH, and not copied from FLASH into some location in RAM, just like every other global variable that is explicitly initialized.  To do that, you need to make the function table const ...

    #pragma DATA_SECTION(FunctionCallTable, "FunctCodeTbl");
    static void (* const FunctionCallTable[])(void) = {

    Note the addition of const.  I presume there are other data sections which are programmed in FLASH.  Handle the section FunctCodeTbl the same way.

    Thanks and regards,

    -George

  • George:

    That worked as advertised.

    I noted a reduction of 0x59 words in the .cinit section. Perfect.

    I was trying to put const between the words static and void, or maybe before static, neither worked.

    I didn't think to put between the asterisk and the function name.

    I do have other data pragmas, and I do have the word const in them and they are OK.

    I tested removing the pragma altogether, and FunctionCallTable ended up in .econst in the flash, so that made my life easier too. I no longer have to create a separate MEMORY or SECTION part in the linker.

    Thanks for your help.

    Mark.