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.

Interrupt handling RB0/INT

Status
Not open for further replies.

myj

Newbie level 2
Joined
Oct 12, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Philippines
Activity points
1,294
Hi all,

Im having problem with my code. i am using mikroC compiler and PIC16F877A Microcontroller.
I incorporate external interrupt RB0/INT as input as i simulated thru the use of PROTEUS the interrupt does not occur. See please my code and have a solution for my problem.

main(){
unsigned int gCOUNT;
TRISB = 0x01;
TRISA = 0x00;

INTCON.GIE = 1; //Enable Global Interrupt
INTCON.INTE = 1; //Enable RB0/INT external Interrupt
INTCON.PEIE = 0; //Disable all unmasked peripheral interrupt
OPTION_REG.INTEDG = 1; //Interrupt on rising edge

if(INTCON.INTF == 1){++gCOUNT;}

}

Thanks,
joenil
 

please take a look at the MikroC for PIc help manual.
Search for "Interrupt" and youi will find information on how to handle inteeupt.
Regards,
 

Hi,
This is the fixed code:
Code:
unsigned int gCOUNT;

void interrupt(void){ //Interrupts must be handled through subroutine like this
     ++gCOUNT;
     INTCON.INTF = 0; //You HAVE to clear interrupt flag
}

void main(void){
    TRISB = 0x01;
    TRISA = 0x00;

    INTCON.GIE = 1; //Enable Global Interrupt
    INTCON.INTE = 1; //Enable RB0/INT external Interrupt
    INTCON.PEIE = 0; //Disable all unmasked peripheral interrupt
    OPTION_REG.INTEDG = 1; //Interrupt on rising edge

    do{ //Repeat endlesssly
    }while(1);
}

Interrupt has to be handled through subroutine as shown. Remember you HAVE to clear interrupt flag in the ISR - Interrupt Service Routine, or that will continue going on. Hope you can understand the code and the mistakes you made.

Hope this helps.
Tahmid.
 
  • Like
Reactions: Taswar

    Taswar

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top