stack overflow detection | Cypress Semiconductor
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?