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.

set ram address to variable in CCS



hi all,

  Initially i was using keil compiler. But now i am shifted to CCS 5.2.

In keil to give particular ram address to variable (global) we used  "__attribute__"

eg.   float a   __attribute__((at(53687)));

In CCS it is giving an warning attribute "at" ignored

What should i use in CCS  to set ram address to variable (global).


Thanks & regards,

Dhanush

  • Hi,

    Not so clear your intentions, specially this: What should i use in CCS  to set ram address to variable (global). Would you like to have some global variables to be seen in different files?

    You may not need to place a variable at a fixed address in RAM - this will lead to some complications - for instance your example placing at 53687 - if real is not good, since the address is not properly aligned at 4 bytes (address % 4 should be 0) - it will generate extra code to pick up bytes from different addresses (modulo 4) and assembling into a register for processing. 

    With CCS, what can you do is to use linker sections where to place variables and these sections must be placed at fixed addresses by the linker (aligned!). A description is here. Also you may search for in CCS forum.

    Petrei

  • Petrei said:
    You may not need to place a variable at a fixed address in RAM

    hi Petrei,

    You told that there is no need to place variable at fixed address,but in my application i want to do that.So tell me how to give particular RAM memory location to global variables.

    In keil it is possible by doing 

    eg.   float a   __attribute__((at(53687)));

    but i dnt know how to do it in CCS.

    Thanks 

    Sagar

  • Hi,

    Did you noticed the link "here" in my previous post?

    Open it and read it - place the variable into a new data section as indicated and modify the linker file (.cmd file) and set up the new section to start up at the needed address. 

    Petrei

  • hi Petrei,

      Thank you peteri for response.

    I have seen it what you have posted. But in my application i want to store my 4,5 big size structure in particular RAM address(known address) and in continuous memory location . The link you have send is for const data member to store in Program memory not in RAM.

    How should i do it for RAM please give me an example,because i am little bit confused.

    Thanks

    Dhanush

  • Hi,

    The method is the same: define a section, a data section and modify the linker file (.cmd) - declare that section in ram, at the wanted address. Take care - in Cortex-Mx the RAM is placed starting with 0x20000000, so any address like you give as example (53687) usually is into flash (only flash can be placed from 0 and is 128…256K). 

    Petrei

    EDIT: attached an example here.

    //****************************************************************************
    // test section in RAM
    #pragma DATA_SECTION(variable, ".infoD")
    float variable = 0.0;
    
    //**************************************
    // do some operation with variable, like
    variable += 20.0
    //***************************************
    
    and the linker file modified as follows:
    
    #define APP_BASE 0x00000000
    #define RAM_BASE 0x20000000
    
    /* System memory map */
    
    MEMORY
    {
        /* Application stored in and executes from internal flash */
        FLASH (RX) : origin = APP_BASE, length = 0x00100000
        /* Application uses internal RAM for data */
        SRAM (RWX) : origin = 0x20000000, length = 0x0002FFFF
        REZRAM(RWX): origin = 0x20030000, length = 0x00010000
    }
    
    /* Section allocation in memory */
    
    SECTIONS
    {
        .intvecs:   > APP_BASE
        .text   :   > FLASH
        .const  :   > FLASH
        .cinit  :   > FLASH
        .pinit  :   > FLASH
        .init_array : > FLASH
    
        .vtable :   > RAM_BASE
        .data   :   > SRAM
        .bss    :   > SRAM
        .sysmem :   > SRAM
        .stack  :   > SRAM
        .infoD  :   > REZRAM
    }
    
    __STACK_TOP = __stack + 1024;