I want to use external interrupt in pic16f877 but cannot get the interrupt. Code is given below.
Why it is not getting ???
I am using switch on RB0 pin and want to toggle the RB1 pin connected with LED.
#include<htc.h>#include<pic.h>void main(){
TRISB0=1;
TRISB1=0;// Configure PortD as output port// INTCON=0x90; // Enable INT0// INTCON2=0; // Set Falling Edge Trigger for INT0
GIE =1;
INTE =1;
OPTION =0x40;// INTCON.GIE=1; // Enable The Global Interruptwhile(1){// LATB=0x55; //Set some value at PortD}}void interrupt ISR(void)// Interrupt ISR{if(INTF==1){
INTF=0;// Clear the interrupt 0 flag
RB1=~RB1;}// Invert (Toggle) the value at PortD// Delay_ms(1000); // Delay for 1 sec}
What IDE and compiler are you using? Have you tried putting the interrupt above the main function? I am not sure if you need that OPTION call, I don't believe I used that before when I did interrupts. What are your configuration bits?