cancel
Showing results for 
Search instead for 
Did you mean: 

Defining table in Flash instead of RAM, IAR

chealy
Associate
Posted on June 11, 2012 at 16:36

Hello,

Wondering if anyone has been able to use IAR to put a table in ROM memory instead of the default RAM with init table.  I would like something like: code int a[] = {1,2,3,4,5,6} or int a[] @ ''abc'' = {1,2,3,4,5}, where abc could be defined in the linker.

Thanks,

AlphaWolfXV

#iar #define #table #stm8
4 REPLIES 4
frankmeyer9
Associate II
Posted on June 12, 2012 at 16:50

In the embedded world, the ''const'' keyword is usually used to achieve this.

It places the qualified variable in the text segment, i.e. where the code is.

Check the IAR help if they do something differently (the often do that...).

And I vaguely remember you need access it at least once to keep the compiler from optimizing it out.

jdf25252
Associate II
Posted on June 12, 2012 at 17:03

Raisonance:

    code int a[] = {1,2,3,4,5,6};

Cosmic:

    const int a[] = {1,2,3,4,5,6};

IAR (I think)

  __code int a[] = {1,2,3,4,5,6};

Good luck

frankmeyer9
Associate II
Posted on June 13, 2012 at 11:43

IAR (I think)...

 

That all boils down to : RTFM

I don't have a IAR installation, but I remember they have a decent help.

... or int a[]

@

''abc'' = {1,2,3,4,5}, ...

I would not do that if not absolutely necessary.

Fixed addresses are for peripheral registers, reset and interrupt vectors, etc, which HAVE fixed addresses.

chealy
Associate
Posted on June 13, 2012 at 11:58

Thanks for the suggestions.  Unfortunately IAR (for STM8) does not recognize the ''__code'' keyword.  What's more is the help for IAR is not stellar for STM8; in the IAR for AVR parts there is mention of a ''__flash'' keyword, but no mention is made in the IAR for STM8 documentation.  I will try the const method above and modify my calling functions.

Thanks for the help.

Cyrus