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.

Internal error: space required for local variables exceeds maximum in main

Other Parts Discussed in Thread: TMS320F28335

Hi,

     I am doing an image processing application. I need to load the data into the stack memory. so the default size is fixed as 0x400. I increased the size of the stack memory yet the error comes as Internal error: space required for local variables exceeds maximum in  _main. Help me out.

 

Thanks,

sandeep

  • Sandeep,

    Which tool is generating this error, is it one of the code generation tools or CCS? Are you trying to load data from a file using probe points? Could you provide more information on how you are loading this data into memory - that might give us a better idea of why this message is appearing.

  • The actual error message is "INTERNAL ERROR: Space required for local variables exceeds maximum in _main".  (Capitalization matters here; when reporting an error, please be sure to cut and paste the exact error message instead of re-typing it.)

    This comes from the compiler when a function's frame (the space for local variables in one function) is too big.  Only C2000, C5500, and MSP430 have this error message, and since the name of the function starts with an underscore, it is not coming from MSP430.  The limit for C2000 is 0xffff 16-bit words, and the limit for C5500 is 0x7ffff 16-bit words.

    The only solution is to reduce the number or size of variables on the stack, probably by moving them to static scope (global variables) or by using dynamic allocation (malloc).

  • Hi Aarti,

                I am using TMS320F28335 ans simulating on CCS3.3. In code i used around three 2-D arrays of size 160*120. while compiling the code itself it popped the error. so i dint yet loaded any data into memory. It gives a stack space error as it has no memory to provide space to local variables. The local variables has to be stored on stack as it specified, but stack has a memory of 0x400 only. so, now how can i use external memory as stack.

  • You will not be able to solve the problem just by increasing the total size of the stack, because the 0xffff limit is for one stack frame.

    Each function instance gets its own stack frame every time it is called.  Stack frames are allocated (in LIFO fashion) in the memory area called the stack. See http://en.wikipedia.org/wiki/Call_stack

    When you adjust the total size of the stack, you are adjusting the size of the memory area.  That option does not affect how large an individual function stack frame can be.

    One of those arrays is 160 * 120 = 19200 words (0x4b00 in hex).  Therefore, you will never be able to have more than two of those arrays as local variables.  Change one of them to be "static".

    I'm not very familiar with C2000, but I suspect you may need to consider using a large memory model.  Still, the maximum size of a stack frame is the same in large model.