Interrupt priority of PIC18 microcontroller

Interrupt priority of PIC18 microcontroller

Interrupt priority of PIC18 microcontroller. An interrupt is a signal sent to a processor that interrupts the current process. It can be created by hardware or software. For example, if a program expects the variable to be a valid number, but the value is null, an interrupt can be created to prevent the program from crashing.


PIC microcontrollers consist of both hardware and software interrupts. If the interrupts are created by external devices on specific pins of the microcontroller, or by built-in devices like timers, it is called a hardware interrupt. Whereas, interrupts are generated by a code snippet in the program.


The method of determining the interrupt priority consists of serial communication of all devices that generate an interrupt signal. The highest priority device is ranked first followed by the lowest priority device and the device with the lowest priority among all devices is ranked last in the series.


In the P1C18 microcontroller there are only two levels of interrupt priority
➢ Low level
➢ High level While address 0008 is assigned to high priority interrupts ,the low priority interrupts are directed to address 00018 in the interrupt . upon
power on reset , all interrupts are automatically designated to high high priority and will referred to address 00008H.This is done to make the PIC18 compatible with the earlier generation of PIC microcontrollers such as PIC16xxx. We can make the PIC18 a two level priority system by way of programming the IPEN (interrupt priority enable) bit in the RCON register.

interrupt priority
interrupt priority

Upon power on reset the IPEN bit contains 0, making the PIC18 a single priority level chip ,just like the PIC16xxx.To make the PIC18 a two level priority system , we must set the IPEN level to high .It is only after IPEN= 1 that we can assign a low priority to any of the interrupts by programming the bits called IP (interrupt priority) .If IPEN = 1 then the IP bit will take affect and will assign a given interrupt a low priority . As a result of assigning a low priority to a given interrupt ,it will land to the address 0018 instead of 0008 in the interrupt .THE IP( interrupt priority) bit along with the IF (interrupt Flag) and IE(interrupt enable) bits will complete all the flags needed to program the interrupt for the PIC18.

Interrupt Flags

interrupts flags
interrupts flags

The INT0 priority flag has only one priority and that is high means that all the PIC18 interrupts can be assigned a high or low priority level except the external hardware interrupt of INT0 .By making IPEN=1 we enable the interrupt priority feature now we must also enable the two bits to enable the interrupts .

We must set GIEH=1. The GIEH bit is part of INTCON register and is the same as GIE ,which we have used . In this regard there is no difference between the priority and no-priority systems ➢ The second bit we must set high is GIEL (part of INTCON ).making GIEL =1 will enable all the interrupts whose IP=0 This means all the interrupts that have been given the low priority will be forced to vector location 00018H.

Interrupt Vector Table

interrupt vector table
interrupt vector table


The INTCON2 and INTCON3 registers allow you to set the priority of some interrupt channels. You can write to these records using the C symbol code.


THE C18 compiler use the reserved keyword Interrupt to designate an Interrupt as an high priority. To assign low priority level to a given interrupt ,it uses the keyword Interrupt low.

Also read here

What are the external hardware interrupts?

Leave a Reply

Your email address will not be published. Required fields are marked *