Searching \ for 'stack overflow error in MpLab' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/languages.htm?key=mplab
Search entire site for: 'stack overflow error in MpLab'.

Truncated match.
PICList Thread
'stack overflow error in MpLab'
1997\05\05@041114 by FrankT

picon face
For those guys who followed my story on the interrupt problems I had,
here's the next chapter.
After a few mails to the piclist and some great help I came up with the
next piece of code.

void __INT(void)
{
       if(PIR1.SSPIF)
       {
               PIR1.SSPIF = FALSE;             // Clear I2C interrupt flag
               INTCON.GIE = FALSE;             // Global interrupt enabled
               save_context;
               I2C_InterruptServiceRoutine();  // decode I2C message
Transmit or receive
               restore_context;
               INTCON.GIE = TRUE;              // Global interrupt enabled

       }
       else if(PIR1.CCP1IF)
       {
               PIR1.CCP1IF = FALSE;            // Clear compare interrupt
flag
               INTCON.GIE = FALSE;             // Global interrupt
disabled
               save_context;
               if (DBS_LaserMode == LAS_MAIN_ON_STATE) // switch of/on
pulse generation
               {
                       LaserFreqOut = ~LaserFreqOut;           // PULSE
GENERATION
               }
               restore_context;
               INTCON.GIE = TRUE;              // Global interrupt enabled

       }
       else if(INTCON.T0IF)
       {
               INTCON.T0IF = FALSE;
               INTCON.GIE = FALSE;             // Global interrupt
disabled
               save_context;
               TMR_InterruptServiceRoutine();  // SYSTEM TIMER
               restore_context;
               INTCON.GIE = TRUE;              // Global interrupt enabled
       }
       return;
}

The problem now is that I receive a Stack overflow error from Mplab when
the timer is generating very fast interrupts, generating pulses from 2kHz
works fine. Once I increase the value the Stack overflow error is displayed



Frank Temmerman

__________________________________________________________________
One fool can ask more questions than all the scientists in teh world can
answer
__________________________________________________________________

1997\05\05@044508 by tjaart

flavicon
face
FrankT wrote:
>
> For those guys who followed my story on the interrupt problems I had,
> here's the next chapter.
> After a few mails to the piclist and some great help I came up with the
> next piece of code.
>
> void __INT(void)
> {
>         if(PIR1.SSPIF)
>         {
>                 PIR1.SSPIF = FALSE;             // Clear I2C interrupt flag

You must save the context (W, Status, and a wealth of other mysterious
MPLABC
variables) first. Here you are going to run into trouble. The include
files for
the various parts in MPLABC do not all contain context saving code. You
cannot
(probably cannot) do this yourself because you don't know how the
compiler uses
these variables.

I ran into this problem with the '74. The support I received from
Microchip stank.
I mailed every Mchip guy from my distributor to every FAE I could find,
but have
still not received ANY constructive feedback after 8 months. What I did
receive was
a whole lot of rethoric about Mchip policy to not update their software
products too
often. They claim the customers would rather sit with malfunctioning
software than
download updates all the time. Geez, don't you just hate PR?

I received a working header file from a guy (not connected to Mchip) on
this list,
but had to promise him I wouldn't mail it to the list or mention his
name. I will
respect that.

What I can suggest, is that you mail a request for a header file with a
working
version of the context saving for your PIC to this list. I'm sure the
Good Samaritan
who helped me will also help you.

If you still don't get help, I will mail him a request on your behalf.

For any prospecting MPLABC buyers out there, I have this piece of advice
:
*****************************************************************************
*** Don't buy MPLABC until Microchip has the competency to offer
support  ***
*****************************************************************************

This may take until next millenium by the looks of it. :(

--
Friendly Regards

Tjaart van der Walt
spam_OUTtjaartTakeThisOuTspamwasp.co.za
_____________________________________________________________
| Another sun-deprived R&D Engineer slaving away in a dungeon |
|             WASP International  http://wasp.co.za           |
|             GSM and GPS value-added applications            |
|  Voice : +27-(0)11-622-8686   |   Fax : +27-(0)11-622-8973  |
|_____________________________________________________________|

1997\05\05@074928 by Andrew Warren

face
flavicon
face
FrankT <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU> wrote:

{Quote hidden}

Frank:

You need to do a few things here...

First, the "save_context code must be THE VERY FIRST thing you do,
right at the start of the __INT() functionm, and the
"restore_context"code must be the very LAST thing you do, just
before the "return".

You didn't mention hether you were using MPC, MPLAB-C, or some other
compiler; some compilers will automatically generate the save/restore
code for you if they know that you're writing an interrupt-service
routine (and they'll also ensure that the "return" is properly
compiled to a "RETFIE" instruction, not a "RETURN").

Second, there's no need for the "INTCON.GIE = FALSE" instructions;
the GIE bit is cleared automatically by the PIC's interrupt hardware.

Third, you MUST NOT set the GIE bit to TRUE within your interrupt
routine; that's what's causing your stack overflow errors.  The
"RETFIE" at the end of your routine will automatically set the GIE
bit true when it returns to your main code.

Other than those three things, your code is fine.

-Andy

=== Andrew Warren - fastfwdspamKILLspamix.netcom.com
=== Fast Forward Engineering, Vista, California
=== http://www.geocities.com/SiliconValley/2499

1997\05\06@122547 by Vishram sarurkar

flavicon
face
On Mon, 5 May 1997, FrankT wrote:
> __________________________________________________________________
> One fool can ask more questions than all the scientists in teh world can
> answer
> __________________________________________________________________
>

Wow !!!! if he can ask so many questions then, i must say he's a genius
not a fool !!!

regards...
vishram.
               +------------------------------------------+
               |            Vishram A. Sarurkar           |
               |           ^^^^^^^^^^^^^^^^^^^^^          |
               |     another hobbyist turned researcher   |
               |   slogging @ Indian Institute of Science |
               |               -----------                |
               |    e-mail:.....vishKILLspamspam.....isu.iisc.ernet.in.        |
               |    Phone:+91 (080) 3092487.              |
               +------------------------------------------+

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...