Other Parts Discussed in Thread: MSP430F5437A
Hello,
we were just experiencing some really stange problem, it is kind of half half SW HW related, since the code runs on a MSP430F5437A:
This uC has about 16 kBytey RAM which should be plenty, we set the Stack really high to 560 ( i think this is decimal and Bytes) for not running into stack overflow problems.
Now I can see in my mapfile that we have about 0x1000 Bytes free, which is 4 kByte of free RAM for my global or volatile or any variable that i want to use.
Now comes the really strange problem, when combining different variables in one function, there are some global ones, and some local ones. For example we did use one global array[512], which starts at RAM address 0x4AC8 ( I can see that variable in the RAM memory view, so I know it is really there, and I know it is right,or at least filles with my values)
So global unsigned int array[512] starts at: 0x4AC8
ends at: 0x4CC8
Now since it is global, I thought the compiler CCS 4.3.x would reserve enough memory, since there still is plenty of unused RAM, and locate that variable where it wont be overwritten. In fact I know now, that one local variable will overwrite my global one at around the middle ( address 0x4BC8) and I simply dont know enough C to say why the hell is it doing so.
My beginners point of view was, global variables will be in the memory of my uC and will not be overlapped with other variables, local variables will only allocate memory, when a function, in which they appear is calles, am I wrong?
Reality did proof me wrong once again :)
Now comes a funny part, we found a workaround: not use a global unsigned int array, but a even longer and volatile unsigned long array.
Can anyone answer why that works and the other way not, always keeping in mind that I have a lot of free space left ( ca. 4 kB)?
Thanks for reading,
best wishes,
Seb