PIC Interrupts vs. Polling

Jump To:
Interrupt Theory
           Now that we know what type of interrupt will be used on the PIC, we need to set it up properly by setting certain values in two important registers. One will enable the interrupt and the other configure the type of interrupt we will be using.

PIC External Interrupt Registers

           To setup the PIC to use interrupts, first we have to enable the interrupt that we want to use. In the PIC 18F452 datasheet the interrupt-on-change enable bit is located in the INTCON register, bit 4. It has the short name INT0IE. We will set this to 1 to enable it. Also, all interrupts need to be enabled, so bit 7, GIE will also be enabled with a 1. This sets up the RB0, interrupt-on-change functionality.


           The second part of setting up the interrupt-on-change register for RB0 is to set whether the state change is a falling edge or rising edge change. The INTCON2 register is where we set this. We will set bit 6 to a '0', since we are designing for a falling edge interrupt. All of this information is located in the PIC 18F452 datasheet, so if you don't have it already, google search for it and download your own copy.



;