I have an interrupt-driven (D-Ts INSTANT INTERRUPTS) I2C slave running (using the SSP hardware). I'm worried that in some instances (like SCL being held low), the interrupt will get "stuck" and never return, thereby "hanging" my slave.
In an attempt to prevent this, I made-
SPP a low-priority interrupt, and TMR4 a high-priority interrupt
The TMR4 interrupt is turned on, but Timer 4 itself is turned off (with T4CON.2 = 0). As soon as the SPP (low-priority) interrupt is entered, it turns TMR4 on. Just before the SPPs INT_RETURN, TMR4 is shut off and cleared.
The goal is that if the SPP interrupt gets stuck, TMR4 will time out, (and being a higher priority) will put things back in order.
The high-priority TMR4 interrupt (which occurs on TMR4 overflow) has only a few instructions:
ASM
unsticker
bcf TMR3,0 ; Stop the timer
clrf TMR4 ; clear the timer
bcf PIR3,3 ; clear the interrupt flag register
retfie 1 ; restore the shadow registers (for the lp interrupt)
INT_RETURN ; Should put me back in the main program
ENDASM
It compiles, but doesn't "unstick" the SPP INT if I (for example) put a PAUSE 1000 in the middle of it. Before I spend a lot of time on this, my question is:
Is this the proper way to get out of a stuck interrupt? Is there a better way?
Bookmarks