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.

EK-TM4C1294XL: Variable declaration in RAM

Part Number: EK-TM4C1294XL

Hi Team,

I am using TI - EK-TM4C129XL board and using IAR for compilation.

_atbit kind of special token is available for TM4C. I want to define a bit variable at a fixed location in the RAM address.

similarly _near I want to use I tried to use _near  for functions getting errors.

storing variable in iram is it possible TM4C? how to do that .

Kindly help.


  • I can explain how to do that with the TI compile tools, but for information on IAR tools you should contact IAR.

  • Thanks Bob. Could you please explain with TI compile tool how to implement, it would be helpful.

    Thank you.

  • OK, here is a simple example that sets bit 3 of the RAM location 0x20000000. There are two parts, the first is to declare a structure with a bit field in the C code. The second part is to bind that structure to a location in RAM. That is done in the link command file.

    Here is the C code:

    #pragma DATA_SECTION(myBitfield, "BitFieldSection")
    volatile struct
        unsigned char b0 : 1;
        unsigned char b1 : 1;
        unsigned char b2 : 1;
        unsigned char b3 : 1;
        unsigned char b4 : 1;
        unsigned char b5 : 1;
        unsigned char b6 : 1;
        unsigned char b7 : 1;
    } myBitfield;
    void main(void)
        myBitfield.b3 = 1;

    Note that we define a structure with bit fields. I declared the structure volatile so that the optimizer would not remove my code. (Without the "volatile" keyword the optimizer correctly sees that there is no value in setting a bit in RAM and then never reading it.) The DATA_SECTIONS pragma is to place the variable in a specific named section so that I can easily reference that variable in the link command file. 

    In the link command file I added line 3 to the "SECTIONS" part that binds the "BitFieldSection" to a specific address:

        BitFieldSection : > 0x20000000
        .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