Placing data structure in SRAM block

28 Jan 2010


In Keil, I thought it was possible to use the "_at_" construct to place a data structure at a fixed address, i.e.


typedef struct
{
int reg1;
int reg2;
} Registers;

Registers regs _at_ 0x20080000;  // Start SRAM block 1.

 

But the online compiler complains. Is Keil not being used behind the sceenes ?

If not, how are we supposed to place data in e.g. the various SRAM blocks ?

Can you provide an example ?

28 Jan 2010

From my USB host code (probably not really necessary for 1768 but still):

// USB host structures
// AHB SRAM block 1
#define HOSTBASEADDR 0x2007C000
// reserve memory for the linker
static USB_INT08U HostBuf[0x200] __attribute__((at(HOSTBASEADDR)));

See documentation here.