Just glancing at your code, you should enable the enable both the Peripheral Interrupts and the Global Interrupt in the initialization area of code, outside of the "while" loop.
Try adding these statements to the end of the following block:
Code:
//Ext Int setup
if (IF) {
OPTION_REG=0x00;
INTCON=0x10; // set INTE; clear GIE, INTF, RBIE, RBIF, TOIE, TOIF
IOCB=0x03; // set IOCB0
PIE1=0x00;
PIE2=0x00;
OSCCON=0x60; //4Mhz internal clock
ANSEL=0x00;
ANSELH=0x00;
WPUB=0x03; // set pull-ups on INT pins
TRISB=0x03;
[COLOR="#FF0000"] INTCON |= 0x40; //set PEIE
INTCON |= 0x80; //set GIE[/COLOR]
}
You should also never allow code execution from exiting main(), through the use of a Super Loop "while(1)" or similar structure.
Unlike systems with OSs, Embedded System without an RTOS or scheduler have no way of controlling the flow of code execution once it has left main().
There maybe other issues as well.
BigDog