ABSTRACT

The interrupt mechanism is a way to avoid wasting processor time, because without interrupts code has to poll hardware devices in ineffective, closed-loops. With interrupts the processor can continue to do its work because the interrupt mechanism ensures that the central processing unit will receive a signal whenever an event occurs that requires its attention. PIC microcontrollers provide varying levels of support for interrupts. This chapter focuses on interrupts on the 16F84. Other members of the mid-range PIC family support interrupts with minor variations. In the PIC 16F84 microcontroller, a change of input signal on port B, lines 4 to 7, generates an interrupt. This interrupt will set the RBIF bit in the INTCON register to indicate that at least one of the ports has changed value. The interrupt handler may have to perform operations that are specific to the application: for example, debounce a switch or initialize local variables.