Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   MPLAB SIM : Stack Overflow Error (http://www.chiefdelphi.com/forums/showthread.php?t=62816)

govvijay 29-01-2008 19:22

MPLAB SIM : Stack Overflow Error
 
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?

Thanks for your help.

kevin.li.rit 29-01-2008 20:20

Re: MPLAB SIM : Stack Overflow Error
 
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.

charrisTTI 30-01-2008 08:38

Re: MPLAB SIM : Stack Overflow Error
 
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.

Joe Ross 30-01-2008 09:46

Re: MPLAB SIM : Stack Overflow Error
 
The 2004 Programming Reference Guide addresses how to get the simulator running. You can download it from this page: http://ifirobotics.com/rc.shtml

I don't know if the simulator works with Kevin's new code, but it does with the IFI code when you follow those instructions.

ayeckley 30-01-2008 10:38

Re: MPLAB SIM : Stack Overflow Error
 
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.

govvijay 30-01-2008 16:46

Re: MPLAB SIM : Stack Overflow Error
 
Could be the new code - we are basing our code off Kevin's gyro code.

robofan 10-02-2008 16:39

Re: MPLAB SIM : Stack Overflow Error
 
I solved stack overflow issue by adding the following code to ifi_frc.h:

#ifdef _SIMULATOR
#define RESET_VECTOR 0x000
#define HIGH_INT_VECTOR 0x008
#define LOW_INT_VECTOR 0x018
#else
#define RESET_VECTOR 0x800
#define HIGH_INT_VECTOR 0x808
#define LOW_INT_VECTOR 0x818
#endif

Also, you need to remove or comment out the following lines in ifi_frc.h:

//#define RESET_VECTOR 0x800
//#define HIGH_INT_VECTOR 0x808
//#define LOW_INT_VECTOR 0x818


All times are GMT -5. The time now is 23:48.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi