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

Use a static variable directly out of the flash memory area

Hello small question,
for my program I use eight large static arrays like,

static unsigned long SP1[64]

and these arrays contains constant values that I need for some calualation in my program this values are never changed. The program code are located in program flash memory. If I remember correctly during the runtime the variable are located (or. copy) in the internal RAM or SRAM (if I use xhuge command for declaration, I found this with the keyword: memory model).

Now my question, is it possible to get this values out of the external flash memory area during the runtime of the program?.

Parents Reply Children
  • Unfortunately not, the read out of a value from the array is simple (you descript it above). But my question is not so simple maybe I explain a little bit more.

    My memory mapping contains the follwing information

    HCONST (0X4200-0XEFFF, 0X10000-0X7F1FE)
    IDATA (0XFA00-0XFDFF)
    HDATA (0X100000-0X13FFEF)
    XDATA (0X100000-0X13FFEF)
    

    with a declaration

    static unsigned long SP1[64]
    


    I think the array will located in internal RAM

    In the meantime I read some user guides and hints and I make my declaration thusly like

    static unsigned long const xhuge SP1[64]
    

    in the listing file contains the following infos

    SP1 . . . . .  static   XCONST array   100H    256
    
    MODULE INFORMATION:   INITIALIZED  UNINITIALIZED
      CODE SIZE        =        4276     --------
      NEAR-CONST SIZE  =    --------     --------
      FAR-CONST SIZE   =    --------     --------
      HUGE-CONST SIZE  =          20     --------
      XHUGE-CONST SIZE =        2304     --------
      NEAR-DATA SIZE   =    --------     --------
      FAR-DATA SIZE    =    --------     --------
      XHUGE-DATA SIZE  =         384     --------
      IDATA-DATA SIZE  =    --------     --------
      SDATA-DATA SIZE  =    --------     --------
      BDATA-DATA SIZE  =    --------     --------
      HUGE-DATA SIZE   =    --------     --------
      BIT SIZE         =    --------     --------
      INIT'L SIZE      =          30     --------
    END OF MODULE INFORMATION.
    

    My Program Flash (512kByte) as the physical adress
    00 0000H - 08 0000H (internal RAM and SFR's 00 F0000h
    01 0000H)

    Now my question once again, can everbody say to me where the array is physical stored in IRAM or in the external Flash?

  • The best way to verify the physical address is to take a look to the linker map file (*.M66 for 166 projects).

    Take a look to:
    http://www.keil.com/support/man/docs/c166/c166_ap_sgc.htm

    What you may have missed is the definition for the XCONST memory class that allows you to locate variables that are define with const xhuge.

    See also:
    http://www.keil.com/support/man/docs/l166/l166_pm_example3.htm

  • OK, first thanks for your answer thats helps

    second the position of XCONST is

    XCONST (0X4200-0XEFFF, 0X10000-0X7F1FE)
    

    Could you explain to me what are the differenc between
    the first and the second settings by XCONST

    XCONST (first settings, second settings)
    

    In special, which memory area (first,second settings) will use if I make a declaration like follow

    static unsigned long const xhuge SP1[64]