Keil™, An ARM® Company

Discussion Forum

Cx51 "const far" struct declaration

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Carlos Santos
Posted
12-May-2008 07:04
Toolset
C51
New! 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.

Read-Only
Author
Walter Conley
Posted
12-May-2008 07:58
Toolset
C51
New! RE: Cx51 "const far" struct declaration

Have you tried this?

typedef struct
{
   BYTE  parameter;
   BYTE  size;
   BYTE  min;
   BYTE  max;
   BYTE  far *var;
} COM_PARAMETERS;
Read-Only
Author
Carlos Santos
Posted
12-May-2008 08:39
Toolset
C51
New! RE: Cx51 "const far" struct declaration

Hello,

I haven't tried that, but the problem isn't with that pointer to a far variable, the problem is with all the struct, because all elements on the struct "have" a value of "zero" when I try to access them...

regards,
Carlos.

Next Thread | Thread List | Previous Thread Start a Thread | Settings