18F Code Snippet - Interrupt Priority

    Swordfish will also handle the priority of your Interrupt Service Routines (ISR's). 18F PIC's support twp different Interrupt priority routines. These are known as High and Low Interrupts.

    If you require an interrupt that needs priority over everything else (including other interrupts), then you must let the compiler know by setting its priority, eg,

Const
    ipLow = 1,
    ipHigh = 2


Interrupt OnTimer1(ipLow)
    // code statements here…
End Interrupt

Interrupt OnTimer3(ipHigh)
    // code statements here…
End Interrupt

    Notice that a value of 2 gives a higher priority to OnTimer3. Now if a OnTimer3 interrupt occurs during OnTimer1 interrupt, then the program will stop what it is doing, and go directly to the OnTimer3 handle. When it has finished, it will return to OnTimer1, and continue like nothing happened. Handy.

    Note: If you try to Enable(Interrupt_Name) to two interrupt of the same priority, a compiler error will occur. By leaving the Interrupt_Name( ) blank (ie, no 1 or 2 in the brackets), the compiler will assign the priorities automatically.

 Skip Navigation Links.

Collapse Site Tutorial IndexSite Tutorial Index
Expand 16F PIC Examples16F PIC Examples
Collapse 18F PIC Examples18F PIC Examples
LED's
Switches
Expand 7 Segment Displays7 Segment Displays
LCD's
Expand 7 Segment Displays7 Segment Displays
ADC
ADC (Another Example)
EEPROM's
DS1307
Expand RS232 and UARTRS232 and UART
DS18B20
External ADC
Hall Effect Sensor
Pulse Width Modulation (PWM)
Infrared UART
Swordfish Modules
Collapse Code SnippetsCode Snippets
SF Libraries
18F Transition Guide
Internal Oscillator
PLL
Structures
Multi Tasking
Expand Internal TimersInternal Timers
Collapse InterruptsInterrupts
Intro
Context Saving
PORTB
Priority
Expand Handy TipsHandy Tips