Structures and XMEM

Does anyone have an example of reading and writing a structure in XMEM?
I need to place a 7000-byte structure ( a mix of chars and int) and can’t work out how to write and read them using normal structure access

What processor? IIRC, on the 4000 and 5000 you can just access the data directly, while on earlier ones you need to use xmem2root()…

Hi,
I am using the RCM4010.
My structure is like
typedef struct {char Model;
char Active;
char MixerID;
int Reading[10];
} METER_DATA;

gldef_d METER_DATA Mixer;

so I amhoping to use lines like
a = Mixer.Reading[4];
and Mixer.Redaing[0] = 0xFF;

What is gldef_d defined to be? If it’s far, you should be OK.

Hi,
actually it is declared as follows

#define GLDEF_C
#define GLREF_C extern
#define GLDEF_D
#define GLREF_D extern
#define LOCAL_C extern
#define LOCAL_D

I have spotted the use of this
#memmap xmem

I have tried adding far to the #define but i still get the same problem… “out of variable space”. I am only declaring around 15-20K of data so am puzzled as to why I am having this problem.

In Dynamic C�s Main menu, you should open Options -> Project Options-> Compiler.

Select �Use separate Instruction and Data Space�
Select �Optimize for Size�

See if that makes any difference for you.

Also see Tech Note 238 located at http://www.rabbit.com/documentation/docs/refs/TN238/TN238.pdf

Also try changing
char Active;
char MixerID;
to
auto char Active;
auto char MixerID;

Hi,

Thanks for that. I had actually tried that yesterday and it did fix my initial problem.
I realise afterwards (and having done a bit more reading) that I was incorrectly thinking that I had direct access to effectively most of the 512K RAM so was surprised that after only about 30K of declarations that I was getting memory space problems. I see that I only have, initially, access to space in a 64K page and that other mechanisms are needed to access the rest of memory.

Although not a concern at the moment for the current project I do need clarification on how to cleanly store/access data in other pages - I will need to store data of various types and structures in the order of 100K and don’t see how to do this easily…