This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

newbie questions about the stack and the stack size

Hi

I have a few questions about the stack size (LPC2200 controller).

E.g. in my programm is a main function with an array

short example[16][500];


16 * 500 * 4 (short) = 3,9 kByte

In which value will I find this array in the calculation when I rebuild all files (code, RO-data, RW-data, Zi-data)?

Moreover is it true, that the stack size will be configurated in the startup file? And the default value is 0x400 for the user stack - so I would need a much bigger value for the user stack?

After a few minutes I saw the map file where I figured out that the stack is growing from a low base.

In my case at the beginning of the internal ram there's a libspace (atmel-lib and string.h) and after that there's the heap (size = 0) and the stack size...

Is it ok, to increase the stack size up to the highest addr from the internal RAM?

best regards
Albert

Parents
  • you got some good advise here. also, be careful not to overflow your stack - you seem to need a lot of space. you can try to fill up an area of RAM just above the stack with a known pattern like "DEADBEEF" of something similar, so that you can detect overflows easier. I don't know your particular chip, but an ARM9 does not have a built in exception in case of stack violations (unless it is equipped with an MMU). generally, stack space is computationally expensive (pushing stuff into it is time consuming) and should be kept for small items only. use RAM for larger items - must you have so much data available to you at any given moment? can't you reuse the memory for different purposes...?

Reply
  • you got some good advise here. also, be careful not to overflow your stack - you seem to need a lot of space. you can try to fill up an area of RAM just above the stack with a known pattern like "DEADBEEF" of something similar, so that you can detect overflows easier. I don't know your particular chip, but an ARM9 does not have a built in exception in case of stack violations (unless it is equipped with an MMU). generally, stack space is computationally expensive (pushing stuff into it is time consuming) and should be kept for small items only. use RAM for larger items - must you have so much data available to you at any given moment? can't you reuse the memory for different purposes...?

Children
No data