This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2541 Store Constants in Code Banks



Hello,

I have to store ~ 40kB const data (some fonts...). The XDATA_ROM_C (0x8000 - 0xffff) is to small to store all the data so I try to put the data into the code area (using code banks).


#pragma constseg = __xdata_rom BANKED_CODE const GuiConst_INT8U Ch000015[16] = { 2,2,2,2,2, 6,6,6,6,6, 2,5, 11,2, 0x1F, 0x03 };


I see the correct result in the memorymap (Ch000015 is linked to banked code instead of xdata_rom_c), to address 0x31c9f.

<BANKED_CODE> 6 (was BANKED_CODE)
  Relative segment, address: CODE 00031C9F - 00031CAE (0x10 bytes), align: 0
  Segment part 21.            Intra module refs:   GuiFont_ChPtrList
           ENTRY                   ADDRESS         REF BY
           =====                   =======         ======
           Ch000015                00031C9F

But when debugging and catching the pointer (void*) of Ch000015, the read out address is not 0x31C9F but 0x9C9F.
I also tried to read the address by using a generic pointer (void __generic *).

How to read out the constants from different code banks correctly?

//* EDIT: Oh, does this known issue concern me? Using IAR EW 8051 IDE 8.20.2

http://supp.iar.com/FilesPublic/UPDINFO/005161/ew/doc/infocenter/icc8051.htm

EW21366
In case the banked code model and the option --place_constants=code is used constants must be placed in the root bank and NOT in a code bank. This is unfortunately still true regardless of whether the device you are working with supports the command line option --has_cobank or not.

greetings,

Elias

  • So, is it possible to place constants in code memory (main bank or banked code) without changing code model to "Banked Extended 2" ?

    Tried some variants with placing constant arrays by using "#pragma constseg = BANKED_CODE". And tried to reference these constants by using generic pointers. But unfortunatly without success so far.

    Are there any possibilities to store constants outside the xdata_rom range, and without changing the whole code / memory model?


    Thank you for responses

  • Hello Elias,

    I don't see you having a problem with the first method you used.  The data is stored in flash along with your program.  There is probably an offset associated with the memory location, I can't remember how exactly it is calculated right now.  You should be able to search for it.  

    There may be a way to search for the memory location using the pointer name in IAR, not sure about that either, but you can read through the IAR IDE guide and see.

    Thanks,