#include<pic.h>
__CONFIG(0x3FE4);
unsigned char carry = 0 ;
void main(){
//Comparator = 0ff
CMCON=0x07;
//Set prescaler to WDT Timer0 = 1:1 Instruction Cycle
OPTION = 0x08;
//Set prescaler on Timer1
T1CON = 0x30; //1:8 prescaler, tmr1 disabled
//PortSetup:
GPIO = 0x00;
//Tristate Output:
TRISIO =0x1F; //All but GPIO5 are inputs
//ALL Digital IP/OP
ANSEL=0x00;
//WeakPullups:
WPU=0x17; //all but GPIO5
//Timer1
TMR1L=0x00;
TMR1H=0x00;
//GPIO Interrupts all but GPIO5
IOCB=0x1F;
//Timer0 & GPIO Interrupt:
INTCON = 0x88; //disable tmr0 interrupt as will pull out of sleep mode
while(carry!=1);
INTCON=0x00;
GPIO5=1;
while(1);
}
//Interrupt Function:
void interrupt tc_int (void){
GPIF=0;
carry = 1;
}