Basic30 Language Reference
Interrupts

An interrupt handler is defined by placing one of the following keywords at the end of a normal Sub definition.

OscillatorFail AddressError StackError MathError INT0Interrupt IC1Interrupt OC1Interrupt T1Interrupt
IC2Interrupt OC2Interrupt T2Interrupt T3Interrupt SPI1Interrupt U1RXInterrupt U1TXInterrupt ADCInterrupt
NVMInterrupt SI2CInterrupt MI2CInterrupt CNInterrupt INT1Interrupt IC7Interrupt IC8Interrupt OC3Interrupt
OC4Interrupt T4Interrupt T5Interrupt INT2Interrupt U2RXInterrupt U2TXInterrupt SPI2Interrupt C1Interrupt
IC3Interrupt IC4Interrupt IC5Interrupt IC6Interrupt OC5Interrupt OC6Interrupt OC7Interrupt OC8Interrupt
INT3Interrupt INT4Interrupt C2Interrupt PWMInterrupt QEIInterrupt DCIInterrupt LVDInterrupt FLTAInterrupt
FLTBInterrupt              

Context Saving:

The lower byte of the Status Register, W0 through W15, and CORCON.3 (IPL3) are saved and restored automatically.  This adds 11 cycles of overhead when calling the interrupt, and 11 cycles when exiting from the interrupt.

Notes:

Example:

Sub DivBy0Trap() MathError
    ' This routine will be executed whenever a math error occurs
    MathErr=0		' IMPORTANT!!! Always zero the interrupt flag before leaving
    ' HANDLE THE ERROR HERE !
End Sub