Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem in externa interrupt in 16f877

Status
Not open for further replies.

ecaits

Member level 4
Member level 4
Joined
Jan 16, 2014
Messages
76
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
579
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.

Plz support.



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#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 Interrupt
    while(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
}

 
Last edited by a moderator:

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?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top