Thursday, March 10, 2016

PIC16F877A External interrupt

PIC16F877A has one external interrupt at RB0/INT pin. When an interrupt occurred, the microcontroller immediately executes the code attached with the interrupt, after finishing the interrupt code the microcontroller returns to the main code. This topic shows to configure and use the external interrupt.
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 hardware interrupt rb0 int ccs pic c circuit
PIC16F877A External interrupt example CCS C code:

// PIC16F877A external interrupt

#include <16F877A.h>
#use delay(crystal=8000000)

void ext_isr(void)
void main()
   while(TRUE) ; // Endless loop