I'm using Codewarrior 5.9.0, coding in C for the HC9S08AW32
In my program, I use a table of function pointers. The table is declared like this:
#pragma CONST_SEG DEFAULT
const void ((*functions[NUM_FUNCTIONS])(void)) =
{
function1,
function2,
function3
};
And the functions are called like this:
functions[i]();
This works fine but the function table is allocated into RAM. Can I get that table to be stored in FLASH?
THX
Solved! Go to Solution.
I seem to have worked it out
const void ((* const functions[])(void))
I seem to have worked it out
const void ((* const functions[])(void))
Yes, exactly.
Probably the void's do not need to be const protected:
void ((* const functions[])(void))={....};
As always with C function pointers, it gets a lot more readable with a typedef:
typedef void (* FunctionPointers) (void);
const FunctionPointers functions[] = {...};
Daniel