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.

array problems

At First, I created a structure that represents a data sample and then created an array made of a number of these  sample structures.  I then tried to populate the samples with data.  It would compile but then the device would not run normally.  

I reduced the complexity of the array populating to the simplest example I could think of and still get the same problem.  The code runs completely normally until I add the "TempArray[TempCounter] = 0; "   line.   then it will compile but not execute.  this is on the 8962 demo board

any ideas. 

 

 

 

int TempArray[100];

 

 

int TempCounter;

 

 

for (TempCounter=1;TempCounter < 50;TempCounter++ )

{

TempArray[TempCounter] = 0;

 

}

 

 

 

 

 

  • joe bullard said:

    At First, I created a structure that represents a data sample and then created an array made of a number of these  sample structures.  I then tried to populate the samples with data.  It would compile but then the device would not run normally.  

    I reduced the complexity of the array populating to the simplest example I could think of and still get the same problem.  The code runs completely normally until I add the "TempArray[TempCounter] = 0; "   line.   then it will compile but not execute.  this is on the 8962 demo board

    any ideas. 

     

     

     

    int TempArray[100];

     

     

    int TempCounter;

     

     

    for (TempCounter=1;TempCounter < 50;TempCounter++ )

    {

    TempArray[TempCounter] = 0;

     

    }

     

     

     

     

     

    Joe,

    I would start by checking the stack size - if you allocate the array within a function or main() it will be pushed onto the stack.  If there is more data than memory allocated for the stack you could be corrupting your code space.     One way to quickly see if this is happening is to fill the stack area with a known value using code composer studio.  Then load the program and run.  You will be able to see how large the stack grew by the values changed.

    Regards

    Lori

     

  • I think you maybe right.  I changed the value of the TempArray[ ] and it works for smaller values.   how do I check/change the stack size?  and how do I know what to set it to?

    Thanks!

     

    -Joe

  • You can change the stack size for a C2000 part under the Project->Properties: C/C++ Build->C2000 Linker options-> C stack size in CCS4.  Make sure you have assigned as much room for the amount set in your linker command file otherwise you may have problems.

    joe bullard said:
    this is on the 8962 demo board

    However, it looks like you are using a Stellaris board.  Unfortunately this is the wrong forum for those so I don't know about setting their stack size.

     

    Tim