#define XTAL_FREQ 16MHZ /* MCU frequency in MHz */
#include <pic.h>
#include "delay.h"
__CONFIG(BOREN & MCLREN & PWRTEN & BORV25 & WDTDIS & INTIO & PLLEN & UNPROTECT);
__CONFIG(VCAPRA5);
void System_init(void){
if (XTAL_FREQ == 16MHZ)
OSCCON=0b00110000;
else if (XTAL_FREQ == 8MHZ)
OSCCON=0b00100000;
else if (XTAL_FREQ == 4MHZ)
OSCCON=0b00010000;
else if (XTAL_FREQ == 2MHZ)
OSCCON=0b00000000;
[COLOR="Red"]ANSELB=0b11111110;[/COLOR] //code correction
TRISB =0b01111111;
RBPU =0;
INTE=1; //enable interrupt at INT pin - RB0
INTF=0;
PEIE=1;
GIE=1;
INTEDG=0; //interrupt on falling edge
}
static void interrupt isr(void){
if(INTF && INTE){
INTF=0;
INTE=1;
}
}
void main(void){
System_init();
while(1){ //looping
RB7=1;
DelayMs(5000);
RB7=0;
DelayMs(1000);
SLEEP();
}
}