This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

array of constants in flash memory

Hello! I need to use a large table of const in my project. I need to locate this constants in concrete adresses on Flash and to access const value by pointing to adress. What is the simpliest way to do this? The table consist of 2000 const. Thanks.

Parents
  • A-w,

    If you're alright with these constant tables having global scope, then it's pretty easy to do. Make a separate C file that includes only the definition for one of your variables. For instance, make a file called ARR1.C and put in it:

    Arr1[2048]={...};

    Then give the linker the following directive:

    ?CO?ARR1(0xC04000)

    Do a similar thing for Arr2. Then you can just extern them elsewhere, or define pointers to them by address, or whatever.

    Note: I've only done it this way by locating a whole module / section at a time, but I have to believe there's some way to tell the linker to locate just that variable. Take a look at the manual, perhaps?

Reply
  • A-w,

    If you're alright with these constant tables having global scope, then it's pretty easy to do. Make a separate C file that includes only the definition for one of your variables. For instance, make a file called ARR1.C and put in it:

    Arr1[2048]={...};

    Then give the linker the following directive:

    ?CO?ARR1(0xC04000)

    Do a similar thing for Arr2. Then you can just extern them elsewhere, or define pointers to them by address, or whatever.

    Note: I've only done it this way by locating a whole module / section at a time, but I have to believe there's some way to tell the linker to locate just that variable. Take a look at the manual, perhaps?

Children