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.

Global variable is getting overwritten by local or other variable even when the scope is alive.?

Other Parts Discussed in Thread: TMS570LC4357, HALCOGEN

Hi all!

This is really new to me in my 2 years embedded experience.

Please anybody resolve this.


I am using TMS570LC4357. and I'm using lwIP Stack library for TMS570LC4357 by TI. When debugging I found this critical situation described in the image below.

Here I have declared lot of variables in my program. So I was doubted that internal RAM memory may be consumed over.

So that my compiler behaves like this (I doubted.) But even if it happens whether the CCS will not show any attention / error message like "RAM memory exceeded!" ?. Without doing this, whether it will do over-writing the memory regions which are already allocated?


Sorry my question is may be stupidly. But It happens. Please anybody guide me how to overcome this.

(Also how to see analysis of Memory utilization in CCS?

like:

 ROM used: X %

RAM used: Y %

ROM free: Z %

RAM Free: P%

)

Is there any analysis option like this?

Expecting a good guidance soon.

Thanks in advance.

Regards,

Karthikeyan.K

  • Hello Karthikeyan,

    It is difficult for me to assess why the global is being overwritten based on the screen shot above. Can you show me the declaration of the global variable?

    If your project is a reasonable size for sharing, you can also attach it in this thread and I can try to take a look at it.

    Finally, it's unrelated, but you define uart8 data[1500] but then assign values to the array elements in a for loop that counts to 1427. This may be intentional, but just to point it out, the maximum value that can be stored in a uint8 is 0xFF or 255 decimal.
  • karthikeyan,

    My apologgies, i neglected to address the memory analysis portion of your post but I am not aware of any feature in CCS that has this capability.
  • Hi Chuck!

    Thanks for your support. Sorry Sir I forget to attach the proof. Here I did attachment which conforms hdkNetIF as global variable.

    So this is why I'm confused.

     I have used HalcoGen generated RTOS code and also lwIP Library code in this project. I don't want SCI1. So I didn't initialise that. But lwIP Library somewhere use SCI1 to send status messages to UART. But I manually disabled sciDisplayText() function. That's all the changes I made.

    Just a suggestion sir.

    This is my previous post I asked about lwIP. This will really helpful when you cross the etharp.c  file while debugging my project.

    Please kindly help me to overcome this problem.

    Thanks a lot sir.

    Regards,

    Karthikeyan.K

  • Karthik, I guess you need to move the array "data[]" out of the stack or make sure you have enough stack space. Also, linker "map" file will give you memory usage of your application.
  • Hello Karthikeyan,

    As Joe has mentioned, this would appear to be a stack size issue. If I recall correctly, the global variables will be defined in the .bss stack where as the local variable will be defined in the .data stack. Given the size of the uchar data[1500] array, this can easily cause a stack overrun. A colleague has suggested to use a malloc instruction to delcare the space. If you do it this way, the space allocation will be moved to the .bss section as I understand it. Subsequently, you will then need to increase the size of the .bss section to handle the additional space of the malloc. Also, be sure and use free to unallocate the space when you are done with it.