MICROCHIP PIC MIDRANGE PIC18XX External Interrupt INT1

Configuring the external Interrupt INT1 in PIC18F25k80 is tricky way. The data sheet also may confuse you well.

Screenshot from 2015-06-24 22:53:21

From the pinout pin 22 or RB1 has multiple functions (RB1/AN8/C1INB/P1B/CTDIN/INT1)

These are the things to be noticed while configuring RB1 as external interrupt

Screenshot from 2015-06-24 23:42:47

The RB1 acts also as analog pin to be exact AN8.From the summary of registers associated with PortB we may misunderstand that ANSEL9 is the pin associated with RB1 but that’s wrong. If you look at ANCON1 resister

Screenshot from 2015-06-24 23:48:45

Screenshot from 2015-06-24 23:49:00

This is the most tricky part in configuring external interrupt.The other configurations are pretty straight forward in INTCONbits.

    TRISBbits.TRISB1 = 1;  
    ANCON1bits.ANSEL8 = 0;
    INTCONbits.GIE = 1;
    INTCONbits.PEIE = 1;
    INTCON3bits.INT1IE = 1;
    INTCON2bits.INTEDG1 = 1;
    INTCON3bits.INT1IP = 1;
    INTCON2bits.RBPU = 0;

The above snippet configures INT1 as external interrupt which responds to a rising edge.