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 Reply Children
  • But i still finding simple solution to locate array of const into concrete address to flash. I have constant arrays Arr1[2048]= {...} which want to locate to 0xC04000 and Arr2[128]={...} to 0xC07D00. With linker i can locate only section, or not? Can i use HARRAY? Please write me example.

  • 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?

  • Whoops... should have looked at your toolset. My example is for C51. The knowledgebase article that Mike references is the same procedure for the C166 toolset though.

  • Thanks. Will test it. But i made next thing: in one C-file declare first array as NEAR and the second array as FAR.
    Now i can locate sections separetly:

    ?FC?CONST%FCONST(0xC04000),
    ?nC?CONST%NCONST(0xC07D00)

    It is works, but it is not a solution to my problem. I want to declare both arrays as NEAR.

    And one small question: Is it important to define section size with SECSIZE directive?

  • Linker gives error:
    ERROR L110: CANNOT FIND SECTION OR REGBANK
    SECTION: ?CO?ARR2

    Directive for linker is:
    ?CO?ARR2(0xC07D00)
    in uVision2 L166 Locate - User Sections

    Maybe i do something wrong?