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.

CCS/TM4C123GE6PM: CCS/TM4C123GE6PM

Part Number: TM4C123GE6PM

Tool/software: Code Composer Studio

Hi,

My code for the TM4C123G  is working fine but as I added two new variables of int data type to the code they are getting the default value 0x84 and 0x03  even I have initialized them with 0x00 and 0x00 and if I change the position of declaration above other variables they work fine but the value of the other value gets affected.I have interrupt  service routine for I2C, DMA and UART in my code.

I tried to make the variables volatile and declared all variable  in another file, included that file as header file. But none of them worked

Any solution to this problem.

  • Hi Akash,
    Are these global variables? How are these variables assigned later on in the code? If the variables are declared in the first file and you want use them in a second file then you need to have the extern declaration on the variable before you use it in the second file.
  • I suggest looking at the location assigned to the variables in the .map file generated by the linker. Did they end up near the end of the stack? Perhaps the stack is overflowing? Were they placed after some array? Perhaps the code is indexing beyond the size of the array. Are the variables 0 when you start the execution of main()? If so, step through your code with the variables in a watch window and you may be able to identify when they get corrupted.
  • Thank you Bob,
    when i have seen the .map file the stack and data section position are reversed. and how to check the stack is overflowing ?

  • The most simple way is to increase the size of the .stack section and see if that solves the problem. Right click on the project and select "Show Build Settings..." and then under Build->ARM Linker->Basic Options, change the stack size. In the example below I increased the stack size to 512 bytes.

    Since the stack is used from top to bottom (as the stack is used, the address is decreased), if the stack uses the lowest RAM locations, you will get a data abort if the stack overflows. In the picture below, I filled my 512 byte stack with 0xFF and ran a simple PWM program. Then by looking at a memory browser I can easily see how much stack space was used. In this case, from 0x200001FF down to 0x200001D8.

    Don't forget the other possibilities of either over indexing an array or a corrupt pointer causing this issue.

  • Thanks a lot bob.
    It worked :)