Hello,
I've just come across a stack related problem using the XC8 compiler and thought I would document my work around.
Here is the warning I receive when compiling.
Uart_Int (1).c: 1884: (1393) possible hardware stack overflow detected; estimated stack depth: 10 (warning)
I’ve been looking through the XC8 compiler manual and there is a way to switch on a software stack.
In the compiler options make a new compiler type for the PIC family with these compiler parameters.
Compiler Parameters
--chip=$(chip) "$(target).c" --MSGDISABLE=359,1273,1388 --RUNTIME=stackcall
The stack controls how many jumps away from main a program can make and be able to find it’s way back to where it was. E.g. macros and components macros each require a level of the stack. A macro that calls another macro uses two levels of stack. Interrupt macros will also use the stack.
I'm using a 16F88 device which I believe has a hardware stack of 8 jumps. The –RUNTIME=stackcall basically uses RAM to store the return addresses when you run out of hardware stack. Beware the software stack has the possibility of corrupting your RAM variables, especially if you are already low on RAM in your program. Maybe try optimising your program or moving to a bigger device.
Here is an exported version of the compiler options you can import using the compiler options import button. Remember to set the option you want to use to be the default option.
XC8 - possible hardware stack overflow detected
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
XC8 - possible hardware stack overflow detected
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel