Keil Logo

C51: Function Pointers in Contiguous Mode


Information in this article applies to:

  • C51 All Versions
  • C51 Version 7.10

QUESTION

I am using the following code with a Maxim (formerly Dallas Semiconductor) 390 target in Contiguous Mode (program size up to 16MB). However, function pointers that are defined with the code attribute fail.

The following program does not work:

typedef void (code *FUNCT_PTR_V_V)(void);
unsigned char IntSrc0;
static void function_0(void){ IntSrc0=0x00; }
static void function_1(void){ IntSrc0=0x01; }

const  FUNCT_PTR_V_V code function_table2[2] ={ function_0, function_1 };

void main(void){
  function_table2[0]();   // function pointer is loaded with invalid value
  while(1);
}

Why do I have this problem?

ANSWER

When working in the Contiguous Mode, you must use generic pointers as function pointers. Only generic pointers store the complete address information which is required. So you need to define the function pointer as shown below:

typedef void (*FUNCT_PTR_V_V)(void);

MORE INFORMATION

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.