AnsweredAssumed Answered

HCS12 banked model &  "near" function pointers

Question asked by Daniel Lundin on Nov 11, 2009
Latest reply on Nov 13, 2009 by Tom Thompson
Environment: CW3.1 and/or CW4.7 for HCS12 (DG128).

I have a project where I am trying to make the entire code portable, as well as MISRA-C compliant. For this, I want to avoid as much non-standard C as possible. Codewarrior has plenty of smart solutions for this through the #pragma keyword. For example I can avoid the interrupt keyword entirely.

One thing I can't figure out however, is how to make function pointers portable. I have an interrupt vector table written in C with "near" function pointers. As I am using the banked memory model, I must explicitly declare them as near or the compiler will try to stuff a PPAGE address into them as well. Though for standard compliance, I don't want this "near" keyword.

I can place functions in non-banked segments by explicitly writing #pragma CODE_SEG NEAR. The actual ISR routines are located in CODE_SEG NEAR, for example. And the vectortable is allocated in CONST_SEG NEAR.

Is there an equivalent for this when it comes to function pointers?

Acceptable solutions would be #pragma or compiler/linker options. I realize it doesn't make sense to make a vectortable code portable, but it would save me a lot of fuss with static analyzers and such tools if the code was pure ISO C.

Outcomes