FrankT wrote: > void __INT(void) > { > if(PIR1.SSPIF) > { > PIR1.SSPIF = FALSE; > interrupt flag INTCON.GIE = FALSE; > save_context; > I2C_InterruptServiceRoutine(); > restore_context; > INTCON.GIE = TRUE; > } > else if(PIR1.CCP1IF) > { > .... etc. .... > } > 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: 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 - fastfwd@ix.netcom.com === Fast Forward Engineering, Vista, California === http://www.geocities.com/SiliconValley/2499