Abhimanyu Kumar

pointer to a function return issue

Discussion created by Abhimanyu Kumar on Aug 3, 2010
Latest reply on Aug 10, 2010 by Pedro Palacios

I am using MC9S12XEQ384.

In my application i have used various function having function pointer as a parameter.The problem is that i am not  getting the exact memory address of the function pointed by the pointer..


One such function is written below:-


f1(char* f2(1), int p,  int j)


 //body of the function.



Char* f2(int i)


switch( i )
         case 0:
           return f3;

         case 1:
            return f4;




char f3( );

char f4( );



In memory f3 is in PAGE 0xFO and f4 function is in PAGE 0XF0, with address 9832 and 9856.

So, the complete address of  function f3 anf f4 become 0xF09832 and 0XF09856.


But, when it is retured from function f2 the pointer is pointing to 0x9832F000 for f3 instead of 0xF09832 and 0x9856F000 for f4 function instead of 0xF09856 depending upon the value of i passed to f2 function.


Do you this my code is not working properly.


Can anybody tell me what is the exact issue and how should i fix it.