Topic : Problem with address space overflow

Forum : 8051

Original Post
Post Information Post
April 4, 2007 - 3:25am
Guest

Hi,

I am using a SiLabs 8051 with the SiLabs IDE and Raisonance toolchain. I am using 'typedef struct' to define data structures containing multiple array elements. I estimate I will need around 1k total effective address space. When I try and assign the arrays to idata or xdata I get an "mspace illegal on struct/union member" error. Does anyone know how to either: assign structure elements to idata or xdata without getting an error, or access the code space configuration settings through the SiLabs IDE?

very much appreciate any help,

admiralfluff

Replies
Post Information Post
+1
0
-1
April 4, 2007 - 10:02am
Guest

Hello,

the memory space directives must be applied to a variable, when declaring it, not to a type definition. The memory space is not part of a type, it is an attribute given to a variable. Let's take the example of a struct: RC51 will locate its member in the same memory space, the one used when declaring the variable of that type. For example:

typedef struct {
   int  array1[10];
   char array2[10];
} mystruct;
[...]
xdata mystruct myvar;

In this example, myvar will be located in XDATA, array1 start address will be the address of myvar, and array2 will be placed just after array1.
A special case applies to pointers: when defining a pointer in your struct, you may want to define the memory space that is pointed to by the pointer. In that case, the following code is allowed:
typedef struct {
   int  array1[10];
   char array2[10];
   code int * ptr1;
} mystruct2;
[...]
xdata mystruct2 myvar2;

myvar2 will be placed in XDATA, and will contain ptr1. But ptr1 will point to a integer in CODE memory space.

I hope it was clear.

regards,
Lionel

+1
0
-1
April 4, 2007 - 6:31pm
Guest

And of course it makes perfect sense.

Thanks Lionel.