Information
© 2007 Microchip Technology Inc. DS80219E-page 3
PIC18F2480/2580/4480/4580
The code segment, shown in Example 2,
demonstrates the work around using the C18
compiler.
EXAMPLE 2: INTERRUPT SERVICE ROUTINE IN C
An optimized C18 version, which illustrates how
to reduce the instruction cycle count to 3, is
provided in Example 3.
Date Codes that pertain to this issue:
All engineering and production devices.
EXAMPLE 3: OPTIMIZED INTERRUPT SERVICE ROUTINE
#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 */
#pragma code high_vector_section=0x8
void high_vector (void)
{
_asm
CALL high_vector_branch, 1
_endasm
}
void high_vector_branch (void)
{
_asm
POP
GOTO high_isr
_endasm
}
#pragma interrupt high_isr
void high_isr (void)
{
...
}