Stored in SRAM RCM6700

I am using the Development Kit Rabbit RCM6700. I have a variable in the code to be stored in the SRAM. I declare:

#class auto
#memmap xmem

bbram typeStruct myStruct;

But the compiler takes me an error: “out of variable data space Please refer to the Dynamic C User’s Manual for more information.”

The RCM6700 has 1M of RAM and 32K of SRAM memory, there is some special statement to access the backup memory space? I am using Dynamic C and 10.72A and configure the compiler option “enable separate instruction & data spaces”

Help me please… !

For variables to be stored in BBRAM use the keyword ‘protected’. This directs the compiler to store your variable in battery-backed RAM.

protected unsigned long MagicNumber;
protected int EPArule, tZone, pattern;

How large is your struct? Know that some of the 32K of SRAM is reserved by the BIOS, specifically if you’re using the FAT filesystem.

This test program of mine compiled fine:

#class auto
#memmap xmem

typedef struct {
	int a, b, c;
} typeStruct;

bbram typeStruct myStruct;

int main()
	return 1;

Be sure to reference the Dynamic C manual on how to properly use protected variables, including calling _sysIsSoftReset(); at the start of main to restore variables that may have been mid-write during a board reset. Also note that “protected” probably won’t work for a structure.

You are right Tom! I forgot about calling _sysIs…(), it’s been a while for me :wink: