Forum : 8051
Original Post
Post Information | Post |
---|---|
April 4, 2007 - 3:25am
|
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 |
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:
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:
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
And of course it makes perfect sense.
Thanks Lionel.