I saw a thread where one person got this error in MPLAB Sim:
CORE-E0001: Stack over flow error occurred from instruction at 0x003d3a
The reply was that you have to use the simulator macro in the build options under the C18. How do you do that? Also, what is the stack over flow error? Why does the “watch” window of the simulator not show the variables used in the program?
A stack is basically memory where you store data temporarily. When you call a function in C, it pushes the data on the stack, after the function returns, it pops it off. The stack is only a certain size and it is possible to push more data onto it than there is memory. I guess that’s when an overflow occurs, I don’t know what’s making it overflow from what you’ve posted.
The two actions relate to the stack are push and pop.
The stack is used in C whenever a function is called. The compiler can use it for passing parameters, storing the address at which execution will resume when the function returns, and temporary storage for local variables (those declared within a function). The stack is a limited resource. Stack overflow can occur if your function call depth is too great. Function A calls B, B calls C, C calls …, you get the idea. At some point you will run out of stack space.
A recursive function (one which calls itself) can generate a stack overflow if it has an error which causes an infinite loop or simply is called recursively so many times that all space is used (as described above).
Post some code if you would like further analysis.
In my recent experience, MPLAB SIM is not compatible with Kevin’s new library. It seems to get hung up waiting for an interrupt during the FRC initialization which never occurs (a timer interrupt, perhaps?). The result is a stack overflow before any of the user code is executed. Stepping over it doesn’t seem to have any net-positive effect. At this point, even if it were working it’s a bit too late in the game to be useful. We wound up using our 2007 bot as a testbed instead.