AnsweredAssumed Answered

Convert __pptr pointer to far pointer in compile time

Question asked by David Stude on May 7, 2008
Latest reply on May 9, 2008 by CrasyCat

Using S12XDP512:

I am creating a table of FLASH ranges across which to calculate CRC.  I'd like to enter in the logical paged addresses (__pptr pointer) into the C file (see below) instead of the global address (far pointer)- primarily because it takes an extra step to convert from what's seen in the PRM linker file to the global address.

The issue I had with this is that casting a __pptr to far pointer seemed to only work at run time....

So, my attempt at, say,

void * far farptr = (void * far) ( (void * __pptr)0xFEFFFF; )  //extra parenthesis to be explicit

would result in farptr being initialized with 0xFEFFFF.

My intermediate solution was to store all the pointer values as __pptr and then at startup I run a cast of all of them:

void * __pptr pageptr = (void * __pptr)0xFEFFFF;
void * far farptr;

int main() {
    farptr = (void * far)pageptr;

But I don't want to use up memory for this extra table unnecessarily.  I'd like the values to be const somewhere and not worry about doing this at runtime.  Can anyone comment on how I can convert these pointers at compile time?

Thank you,