EXTERNAL INTERRUPT CONFIGURATION IN PIC16F877A
- External interrupt pin of pic16f877a is RB0.
- for setting external interrupt first set TRISB=0x00;(as output)
- Then GIE=1,PEIE=1 and INTE=1
- Then write interrupt service routine
- When interrupt happen the flag INTF will set.
- Then clear the flag in interrupt routine itself for next interrupt
- sample code is given below.
#include<pic.h>
int i;
void interrupt isr()
{
if(INTF==1)
{
i++;
INTF=0;
}
}
void main()
{
TRISB=0x00;
GIE=1;
PEIE=1;
INTE=1;
while(1);
}
This is the program for external interrupt in pic 16f877a micro controller
No comments:
Post a Comment