With EWARM, you can place variables with a few methods. You can place at a specific address using @
. From IAR's support site:
const char RELEASEDATE[16] @ 0x0000FF10 = __DATE__ ;
const char RELEASETIME[16] @ 0x0000FF20 = __TIME__ ;
Alternatively, you can locate variables in a section (which sounds like what you want) using the location pragma. From the same source:
#pragma location = "ConstSection1"
__root const char RELEASEDATE[16] = __DATE__ ;
#pragma location = "ConstSection2"
__root const char RELEASETIME[16] = __TIME__ ;
And in your linker file (.icf
) you would have:
place at address mem: 0x0000FF10 { readonly section ConstSection1 };
place at address mem: 0x0000FF20 { readonly section ConstSection2 };
I prefer the #pragma
as the @
operator looks out of place. Additionally, someone reading the code expects #pragma
to be something compiler specific, while @
hides itself in the code and doesn't stand out.