IAR const placement

All design tool related questions: compiler, assembler, linker. Embedded programming questions: assembler, C code.

Moderator: nferre

Posts: 10
Joined: Tue Nov 27, 2007 11:05 am

IAR const placement

Fri Jun 05, 2009 11:31 am

Dear All,
Iam going from IAR embedded workbench 4.x to 5.x. There are some differences

in sections and so on.
If I place empty const array in eeprom, linker automaticly fill it by 0.

in old versin (const unsigned short Test[300] @ 0x01234) creates array with

old values which was stored in FLASH before programming.
in new versin (const unsigned short Test[300] @ "sectionTest") creates
array nad programmer fill it by zero.

how can I do in IAR embedded workbench to reserve const arrary in any
address in FLASH with old values??

Thank you for repply
Best Regard multis
Posts: 10
Joined: Tue Nov 27, 2007 11:05 am

Re: IAR const placement

Wed Jun 10, 2009 9:37 am

answer of IAR support:

The problem is that you must use:

__no_init unsigned char CP[84000] @ 0x27200;

instead of:

__no_init unsigned char CP[84000] @ "0x27200";

Note that "0x27200" is treated like a section and not like an address.

Anyhow I found a solution for the problem when using sections on the
declaration, for example:

__no_init const unsigned char CP[84000] @ "eCP";

eCP is not "readonly", so replace:

place at address mem: 0x027200 { readonly section eCP};


place at address mem: 0x027200 {section eCP};

do not initialize { section eCP};

You must also add do not initialize {}; to the .icf file. Otherwise the data
initialization function will try to set those two sections to zero at system
start. The need for this is not obvious in the development guide - it will
be improved in V5.40. See description of "Do not initialize directive" in
the development guide.

The advantage of using a section instead of the address on the declaration
is that you can use "const" and the compiler can avoid writing to this
Posts: 7
Joined: Thu Apr 30, 2009 7:46 am

Re: IAR const placement

Fri Jun 12, 2009 8:05 am

thank you for sharing your usefull reply.

Return to “Development Tools”

Who is online

Users browsing this forum: No registered users and 3 guests