Hi im trying to call functions from a string the microcontroller receives. To do this the micro controller find recieves and compares this to the names in the peripheral name list. It uses the index to get a pointer to a list of functions names available for that peripheral and then compares then function name to that list to get a functions index. These two indices are then used to call the functions.
The system works fine for 2 peripherals but then adding a third causes the program to stop running, sometimes it gives the warning stack pointer is out of range, other times it will just show no position when the program is paused. Adding a third peripheral to the peripheral_fnct_pntr_pntr list causes this to happen, it functions fine with all combinations of 2 peripherals and commenting the line will work aswell.
I made custom types for functions pointers as shown:
typedef void (*fp)(int); //Declares a type of a void function that accepts an int
typedef char (*p)[6][20]; //pointer to array
the lists of funstions and pointers are created as shown:
char peripheral_names[6][20] = {"rgb","button"}; //[no of strs][size of str]
char rgb_fnct_names[6][20] = {"rgb_brightness","red_brightness","green_brightness","blue_brightness","rgb_onTime","rgb_breath"};
char led1_fnct_names[6][20] = {"led1_brightness","led1_onTime","led1_breath"};
char led2_fnct_names[6][20] = {"led2_brightness","led2_onTime","led2_breath"};
//store pointers linking name to functiion index to function
//rgb led functions pointers
fp rgb_fnct_pntrs[] = {&rgb_brightness,&red_brightness,&green_brightness,&blue_brightness,&rgb_on_time,&rgb_breath};
//led function pointers
fp led1_fnct_pntrs[] = {&led1_brightness,&led1_on_time};
fp led2_fnct_pntrs[] = {&led2_brightness,&led2_on_time};
//store list of ponters to peripheral function pointer lists
fp *perph_fnct_pntr_pntr[] = {rgb_fnct_pntrs, led1_fnct_pntrs, led2_fnct_pntrs};
//store pointers linking peripheral name index to list of function names
p name_to_fnct_lst[3]= {&rgb_fnct_names,&led1_fnct_names,&led2_fnct_names};
Im not sure whats causing this problem so any help would be appreciated.