Information

PIC18F2480/2580/4480/4580
DS80496C-page 6 2010 Microchip Technology Inc.
2. C Language Programming:
The exact work around depends on the
compiler in use. Consult the C compiler’s
documentation for details.
If using the Microchip MPLAB
®
C18 C
Compiler, define both high and low-priority
interrupt handler functions as “low priority” by
using the pragma interruptlow directive.
This directive instructs the compiler to not use
the RETFIE FAST instruction. If the proper
high-priority interrupt bit is set in the IPRx
register, the interrupt is treated as high priority
in spite of the pragma interruptlow
directive.
The code segment, shown in Example 2,
demonstrates the work around using the C18
compiler.
EXAMPLE 2: INTERRUPT SERVICE ROUTINE IN C
#pragma interruptlow MyLowISR
void MyLowISR(void)
{
// Handle low priority interrupts.
}
// Although MyHighISR is a high priority interrupt, use interruptlow pragma so that
// the compiler will not use retfie FAST.
#pragma interruptlow MyHighISR
void MyHighISR(void)
{
// Handle high priority interrupts.
}
#pragma code highVector=0x08
void HighVector (void)
{
_asm goto MyHighISR _endasm
}
#pragma code /* return to default code section */
#pragma code lowVector=0x18
void LowVector (void)
{
_asm goto MyLowISR _endasm
}
#pragma code /* return to default code section */