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.

problem about autoinitialization of global variables assigned explicitly

Dear friends, I'm debuging  my custom board with a LM4F232H5QC chip on it, the software tool is CCS V5.2, the emulator is XDS100V3。I found that global variables which were assigned explicitly  couldn't be autoinitialized by the _c_int00(); the initialization model is "link using ROM autoinitialization model". Could anybody help me?

  • What do you mean by could not be initialized?

    Can you give a quick sample code sequence that shows the issue that you are having?

  • #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include "rom.h"
    #include "rom_map.h"
    #include "quemanage.h"
    #include "led.h"
    #include "uartapp.h"
    #include "powersetup.h"
    #include "statusmonitor.h"
    #include "ticktimer.h"

    char LED_Buff[32];
    char LED_Number[6]={0,2,4,5,7,9};      //when I run the code, i found the  LED_Number[]  is not initialized.
    unsigned long LogicError;


    /****************************************************************************/
    //点亮指定LED。
    void LED_Control(unsigned char led_no,unsigned char led_color)
    {
    sprintf(LED_Buff,"LED,%d,%d\r\n",led_no,led_color);
    Display_Char_Send(LED_Buff);
    }

    /****************************************************************************/
    // LED测试
    void LedTest()
    {
    unsigned long i;

    //检测所有的LED,延迟50ms
    for(i=0;i<10;i++)
    {
    LED_Control(i,LED_COLOR_OFF);
    }

    MAP_SysCtlDelay(50 * MAP_SysCtlClockGet() / (3 * 1000));

    for(i=0;i<6;i++)
    {
    LED_Control(LED_Number[i],LED_COLOR_RED);
    }

    MAP_SysCtlDelay(200 * MAP_SysCtlClockGet() / (3 * 1000));

    for(i=0;i<6;i++)
    {
    LED_Control(LED_Number[i],LED_COLOR_YELLOW);
    }

    MAP_SysCtlDelay(200 * MAP_SysCtlClockGet() / (3 * 1000));

    for(i=0;i<6;i++)
    {
    LED_Control(LED_Number[i],LED_COLOR_GREEN);
    }

    MAP_SysCtlDelay(200 * MAP_SysCtlClockGet() / (3 * 1000));

    }

  • Nothing looks out of place there, what startup code are you using?

    Our projects come with a startup_ccs.c that call the C init function and this might be missing in your project.

    Here is a stub of our reset function.

    void
    ResetISR(void)
    {
    //
    // Jump to the CCS C initialization routine.
    //
    __asm(" .global _c_int00\n"
    " b.w _c_int00");
    }

  • The startup_ccs.c provided by TI is added in my project  ,and the funtion ResetISR() is the same as what you provide. please see the inserted map file.7360.dtvpwc100w.txt

  • Is this a project that you created yourself or built from one of our examples?

    There has to be something very basic wrong in the project file for it to not initialize globals

    You also might want to post over in the ccs forum to see if they have an idea what is going on as well.

  • Paul, I found the global variables were autoinitialized  correctly, but they were modified by function "sprintf()" , when I tried to increment the size of the Stack, the problem was solved, the cause is stack overflow.