// Lesson #10 - Interrupt-on-change

int i = 0;

void blink(void){

for(i = 0; i<4; i++){

GPIO.B0 = 1;

Delay_ms(100);

GPIO.B0 = 0;

Delay_ms(100);

}

}


void interrupt(void){ // ISR

if(INTCON.GPIF == 1)

{

INTCON.GIE = 0;

blink();

INTCON.GPIF = 0;

INTCON.GIE = 1;

}

}


void main(void){

TRISIO = 0b00000100;

CMCON0 = 0x07;

ANSEL = 0;

ADCON0 = 0;

INTCON.GIE = 1;

INTCON.GPIE = 1;

IOC.IOC2 = 1;

while(1){//Do nothing

}

}