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.
Thanks for any help on this,
Mark