Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

Initialization of global array doesn't work

Other Parts Discussed in Thread: TMS320F2808

I'm using CCS5.3 for TMS320F2808.

In my code, I defined a global array with initialization, such as

int arr[] = {1, 2, 3};

When I loaded the program and began debugging the program in CCS, the array is of length 3, but the initial value of every element was set to zero.

As I know, this method to defined an initialized array is normal practice. Why it doesn't work for this compiler?

Thx

Xiang Chao

  • Xiang,

    It has to work.  There must be something more going on.  I assume arr[] is a global variable.  Neither the processor nor the compiler initializes any variables to 0 (although the Simulator does - are you using the simulator?).  So, it is suspicous that you say the array is initialized to zero.

    The intialization for globals occurs in a routine called _c_int00(), part of the rts library.  This runs before main().  Did you run through the _c_int00 routine to main() before checking the array values?

    Do you have ROM Autoinitialization model selected for the runtime mode in the linker options?  You must use ROM model for the initialization to occur.

    - David

  • Last time, after selection ROM autoinitialization model, it worked.

    But today, this problem come out again. And I am quite sure that I chose the right initialization model.

    What is the problem?

    Thanks

  • Xiang,

    I really cannot say what is going on in your system.  There is not enough information to even speculate.  You either have something setup wrong, are perhaps are doing something with the debugger that you shouldn't be doing (e.g., bypassing _c_int00 somehow).

    I'd suggest taking a TI example and working from there.  Appnote SPRA958 has complete standalone code with it that does some simple tasks.  Suggest using either the F2808_nonBIOS_RAM or F2808_nonBIOS_Flash example.

    http://www.ti.com/mcu/docs/litabsmultiplefilelist.tsp?sectionId=96&tabId=1502&literatureNumber=spra958l&docCategoryId=1&familyId=1414

    Regards,

    David