PIC16F877A External interrupt example circuit:
The following circuit schematic shows a simple circuit that turns on and off the LED connected to RC0 using a pushbutton connected to RB0 pin. The external interrupt is used to toggle the status of the LED.
PIC16F877A External interrupt example CCS C code:
// PIC16F877A external interrupt
// http://ccspicc.blogspot.com/
// electronnote@gmail.com
#include <16F877A.h>
#use delay(crystal=8000000)
#INT_EXT
void ext_isr(void)
{
clear_interrupt(INT_EXT);
output_toggle(PIN_C0);
}
void main()
{
output_low(PIN_C0);
ext_int_edge(H_TO_L);
clear_interrupt(INT_EXT);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
while(TRUE) ; // Endless loop
}