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.

SRAM initialization



I'm using the LM4F232H5QD and want to reserve a memory location in SRAM. The problem is whenever I do a reset in the Code Composer Debugger the memory location always is reset to zero. I did the following in the linker command file:

SECTIONS
{
    .intvecs:   > 0x00000000
    .text   :   > FLASH
    .const  :   > FLASH
    .cinit  :   > FLASH
    .pinit  :   > FLASH

    .vtable :   > 0x20000000
    .data   :   > SRAM
    .bss    :   > SRAM
    .sysmem :   > SRAM
    .stack  :   > SRAM
    .reserved > 0x20007FF0

}

The .reserved at 0x0x20007FF0 I want to preserve a value after reset.

In C I have the following:

#pragma SET_DATA_SECTION (".reserved")
static unsigned long foo;
#pragma SET_DATA_SECTION ()

void main(void)
{
    foo  = 123;

    while (1) ;

}

In the memory browser this value will be set to zero after a reset.

In looking at the disassembly and stepping through a reset I see a label __TI_auto_init .  Is this the routine that initializes ram? Where is the source to this?

Help will be appreciated.

Bob




  • Robert Keyes said:

    In looking at the disassembly and stepping through a reset I see a label __TI_auto_init .  Is this the routine that initializes ram? Where is the source to this?

    In EABI mode (which is the default mode for LM4F232 projects in CCS) global variables that are not explicitly initialized get initialized to zero in the init routine. This is documented in the ARM COmpiler Users Guide, section 6.9.3.

    If you wish to take a look at the code for the init routine, you can extract the runtime sources (unzip the file rtssrc.zip found in \ccsv5\tools\compiler\arm_5.0.1\lib\ within the CCS installation) and take a look at file auto_init.asm.

     

  • Thanks very much for your help.

    Bob