2 Replies Latest reply on Feb 28, 2014 3:48 AM by legic_1490776

    Stack overruns and max stack size

    legic_1490776

      I ran out of stack space in my application, but only discovered this by seeing clobbered ram.

       

      1. is there any good way to detect stack overrun (e.g. declaring a variable at the top of the stack region and check for magic number?  If so what is the best way to do this?

       

      2. is there a way I can increase the allocation to the stack?

       

      Thanks!

        • 1. Re: Stack overruns and max stack size

          Hello Idgirod,

           

          1. Is there any good way to detect stack overrun (e.g. declaring a variable at the top of the stack region and check for magic number?  If so what is the best way to do this?

           

          [JT] -See below

           

          // This returns the number of bytes free till the top of RAM at the point of invocation.
          UINT32 cfa_mm_MemFreeBytes(void);

          // This function returns 0 if a stack overflow was not detected before
          // Else it detected an overflow.
          UINT8 blecm_DidStackOverflow(void);

           

          2. Is there a way I can increase the allocation to the stack?

          [JT] - Increasing the application stack size is not supported.

           

          Let me know if this answers your questions.

           

          JT

          • 2. Re: Stack overruns and max stack size
            legic_1490776

            Thanks, this does answer my question