Total Pageviews

Tuesday, January 28, 2014

EXTERNAL INTERRUPT CONFIGURATION IN PIC16F877A

EXTERNAL INTERRUPT CONFIGURATION IN PIC16F877A


  1. External interrupt pin of pic16f877a is RB0.
  2. for setting external interrupt first set TRISB=0x00;(as output)
  3. Then GIE=1,PEIE=1 and INTE=1
  4. Then write interrupt service routine
  5. When interrupt happen the flag INTF will set.
  6. Then clear the flag in interrupt routine itself for next interrupt
  7. 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