This topic is a small example shows how to use PIC16F84A external interrupt.
PIC16F84A external interrupt example circuit:
In the circuit schematic above we have just a button and an LED , the button is connected to the external interrupt RB0/INT pin and the LED is connected to RA0 pin. When the button pressed, an interrupt occurred and the LED will toggle its state.
// PIC16F84A external interrupt example
// http://ccspicc.blogspot.com/
// electronnote@gmail.com
#include <16F84A.h>
#fuses HS,NOWDT,PUT,NOPROTECT
#use delay(crystal=8000000)
#INT_EXT
void ext_isr(void)
{
output_toggle(PIN_A0);
}
void main()
{
output_low(PIN_A0);
ext_int_edge(H_TO_L); // Interrupt on falling edge of RB0/INT pin
clear_interrupt(INT_EXT); // Clear RB0/INT external interrupt flag bit
enable_interrupts(INT_EXT); // Enable RB0/INT external interrupt
enable_interrupts(GLOBAL); // Enable all unmasked interrupt
while(TRUE) ; // Endless loop
}
PIC16F84A external interrupt example video:
The following video has some details about the circuit and the CCS C code.