2 Replies Latest reply on Oct 23, 2013 12:30 PM by userc_42988

    stack overflow detection

      I followed the example in Appendix B of http://www.cypress.com/?docID=42246 to detect a stack overflow in software.  Basically, pre-set the SRAM byte at 0xFF to value of 0xAA.  Then periodically check to make sure it hasn't changed.


      Seems like a good idea, but I am getting false-positives.  I verified there is no stack overflow by using the ICE with Events as also described in that document.


      Seems the function E2Read() is stepping on that ram location.  Then I checked the datasheet for E2PROM, and it indeed says that the E2Read() uses "RAM High Memory: 0xF8 - 0xFF".


      That doesn't seem like a safe practice to me.  So there is no hardware to detect a stack-overflow, no way to statically set the stack size, and functions that write to the stack area without using the stack pointer?  Am I missing something?

        • 1. Re: stack overflow detection

          You can set the beginning of the stack from 0 to 0xff and of course you can write into the stack area even with C.


          When something within your program goes wrong and you'd like to get some help you should be a bit more specific:


          Which PSoC1 are you using, what are the settings etc.


          If you can, use Designer -> File -> Archive Project and upload (best is to use ms internet explorer, chrome doesn't work) the resulting archive so that we all can have a loook at.





          • 2. Re: stack overflow detection

            My post was meant more as a complaint than a question.


            I got it working by setting the pre-set value address (end-of-stack address) as 0xF7 (accounting for the 8 bytes used by the E2Prom library).