How to work with External (Hardware) Interrupts of PIC18F4550




Interrupts are special events that require immediate attention. They cause the processor to cease the running task to serve a special task for which the interrupt event had occurred. After the special task is over, the processor resumes performing the original task.

Interrupts of PIC

The processor can also serve these events by polling method. But polling is an inefficient technique as compared to interrupts. In the polling method, the processor has to continuously wait for the event signal. Thus it always remains busy using extra resources. To understand the difference between polling and interrupts well, refer introductory paragraphs of 8051 Interrupts.
This article is based on PIC18F4550 microcontroller’s interrupt system. The configuration and implementation of PIC Hardware Interrupts are explained here.

A PIC microcontroller consists of both software and hardware generated interrupts. The hardware interrupts are produced by external hardware at certain pins of the microcontroller. The software interrupts, on the other hand, are generated by internal peripherals of the controller. This software interrupt helps the programmer to use more than one internal peripheral in single application and serve them individually when they respond.

Following is an example to illustrate the interrupts better. Suppose a programmer wants to make a real time watch which shows ambient temperature as well. The programmer has to use two internal peripherals of the controller, namely, a Timer and an ADC channel. Consider this project without using interrupt : the programmer has to take care of both peripherals one by one continuously by polling them. This is not an efficient way of programming.
In Interrupt method, the controller serves the Timer when it overflows and the ADC when the A/D (analog to digital) conversion is done. Along with these, the microcontroller can also perform other tasks, like displaying some text on LCD. Therefore use of interrupt makes the program more efficient and logical.
When an Interrupt occurs in a PIC Microcontroller, the program execution gets transferred to a predefined Interrupt Vector Address from where the processor gets what operations to perform in for a particular interrupt occurrence. The detailed working of interrupts can also be studied from 8051 Interrupts or AVR Interrupts.
Interrupts in PIC18F4550:
PIC18F4550 has following internal and external interrupts:

·         Reset, Brown-Out Reset, Watch-dog Reset, Power On Reset

·         External Interrupt 0 (INT0)

·         External Interrupt 1 (INT1)

·         External Interrupt 2 (INT2)

·         Timer 0 Interrupt

·         Timer 1 Interrupt

·         Timer 2 Interrupt

·         Timer 3 Interrupt

·         ADC Interrupt

·         Analog Comparator Interrupt

·         RB Port change Enable Interrupt

·         Streaming Parallel Port Read/Write Interrupt

·         EUSART Receive Interrupt

·         EUSART Transmit Interrupt

·         Master Synchronous Serial Port Interrupt

·         CCP1 Interrupt (Capture, Compare, PWM)

·         Oscillator Fail Interrupt

·         USB Interrupt

·         Data EEPROM/Flash Write Operation Interrupt

·         Bus Collision Interrupt

·         High/Low-Voltage Detect Interrupt

·         CCP2 Interrupt

A total of 10 registers are used to control the interrupt operation in PIC18F4550 which are as follows:




Current Project / Post can also be found using:

  • picmicro tutorial

Leave a Comment

*
= 5 + 9

Read previous post:
FTDI Chip adds EVE Screen Designer

Bringing more comprehensive support to its Embedded Video Engine (EVE) product offering, FTDI Chip introduces EVE Screen Designer – which...

Close
Scroll to top