Environment:
IDE:Codewarior 5.1,MCU:MC9S12GA192
How do I call a function from a function pointer?
1. If the function name of the called function is directly assigned to the pointer, it is ok to call the function with the pointer, and jump to the function:"HAL_E_IDLE_Task()".
void (*function_ptr)(void);
function_ptr = HAL_E_IDLE_Task; //or "function_ptr = &HAL_E_IDLE_Task;"
(*function_ptr)(); //or "function_ptr();"
This will call the function successfully!
2. But if the function is compiled after the link stored in flash address assigned to the pointer, and then call the function, the program will run away, can not enter the function "HAL_E_IDLE_Task()".
void (*function_ptr)(void);
function_ptr = (void (*)())0x0000CF1F; //Function "HAL_E_IDLE_Task()"compiled link addresses:"0x0000CF1F"
function_ptr(); //or"(*function_ptr)();"
This way can not call the function successfully!
I need to call the function in the second way(Use Function Point address), how can I jump to the function "HAL_E_IDLE_Task()" correctly?
PS:S32DS for SPC5744P(Power Architecture) use second way can call the function successfully!It is Complier reason?