What did I do wrong? - Interrupt on change bit

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
I have a momentary contact switch tied to +5V and connected to RB6 of a 18F14K22.

I can see the input changing state via the debugger but the interrupt does not seem to be working when the button is pressed. I know it is probably something simple but I am just not seeing it.


Rich (BB code):
void InterruptServiceHigh(void);


//----------------------------------------------------------------------------
// High priority interrupt vector

#pragma code InterruptVectorHigh = 0x08
void InterruptVectorHigh (void)
{
  _asm
    goto InterruptServiceHigh //jump to interrupt routine
  _endasm
}
#pragma code    // declare executable instructions




void VoltSel_Init()
{

    ANSELH=0;
    TRISBbits.TRISB4 = 0;        //Setup for output
    TRISBbits.TRISB5 = 0;        //Setup for output
    TRISBbits.TRISB6 = 1;        //Setup for input (button)

    INTCON2bits.RABPU = 0;        // enable PORTB internal pullups
    WPUBbits.WPUB6 = 1;            // enable pull up on RB6
    IOCBbits.IOCB6 = 1;

     // Set up switch interrupt on INT0
    INTCON2bits.INTEDG0 = 0;    // interrupt on falling edge of INT0 (switch pressed)
    INTCONbits.INT0IF = 0;      // ensure flag is cleared
    INTCONbits.INT0IE = 1;      // enable INT0 interrupt
      INTCONbits.GIEL = 1;        // Low priority interrupts allowed
    INTCONbits.GIEH = 1;        // Interrupting enabled.

    // NOTE: INT0 is ALWAYS a high priority interrupt

    // Set up global interrupts
    RCONbits.IPEN = 1;          // Enable priority levels on interrupts
}
 
Top