This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cx51 "const far" struct declaration

Hello,

I'm having some problems regarding const far memory type in Cx51...

Using the following declarations, the variables aren't being initialized correctly, and accessing them, results in values of "zero".

I'm using Philips/NXP P89C669 in MX mode (rom huge memory model).

The struct definition is as follows:

typedef struct
{
   BYTE  parameter;
   BYTE  size;
   BYTE  min;
   BYTE  max;
   BYTE  *var;
} COM_PARAMETERS;

And the COM_PARAMETERS declaration and initialization is as follows:

BYTE far var1;
BYTE far var2;
BYTE far var3;
BYTE far var4;

const far COM_PARAMETERS comms_parameters[5] =
{
   { 0, 0, 0, 0, 0 },
   { 1, 1, 0, 1, &var1 },
   { 2, 1, 0, 1, &var2 },
   { 3, 1, 0, 1, &var3 },
   { 4, 1, 0, 9, &var4 }
};

Some other typedef's used above:

typedef unsigned char BYTE;

If I try to access comms_parameters[2].parameter or any other array element or struct member, I always get "0". I've tried to "watch" the comms_parameters in uVision3 Simulator, but not even in the simulator it works - I try to "drag&drop" the variable to the watch window, failing in doing so...

Does anybody has a clue on how to solve this issue?

Regards,
Carlos.

0