I have read every post I can find and still do not understand why external interrupts are not triggering, the following is my initialization, it is not clean, as I am in the process of trying everything I can think of to make this work.
To simplify the problem, consider only INT1.
Update: It appears the flag is getting triggered, but the ISR is never being executed. The flag is not being lowered
void __attribute__((__interrupt__, no_auto_psv)) _INT1Interrupt(void)
{
IFS1bits.INT1IF = 0; //Clear the INT1 interrupt flag
//U1TXREG='0';
m_Capture1 = 1;
}
// Hall Sensor A | Pin 31 RPI24 RA8
// Disable all other pin functionality.
TRISAbits.TRISA8 = 1 ;
//LATAbits.LATA8 = 0;
ODCAbits.ODCA8=0;
CNENAbits.CNIEA8=0;
CNPUAbits.CNPUA8=0;
CNPDAbits.CNPDA8=0;
//INTCON1bits.NSTDIS = 0; // interrupt nesting enabled.
//INTCON2bits.GIE = 1; // Global Interrupt Enable.
INTCON2 = 0x0000; // all interrupts on rising edge.
// Reset Interrupt flags.
IFS0bits.INT0IF = 0; //Reset INT0 interrupt flag
IFS1bits.INT1IF = 0; //Reset INT1 interrupt flag
IFS1bits.INT2IF = 0; //Reset INT2 interrupt flag
INTCON2bits.INT0EP = 1 ;
INTCON2bits.INT1EP = 1 ;
INTCON2bits.INT2EP = 1 ;
// Enable Interrupts.
IEC0bits.INT0IE = 1; // Enable INT0 Interrupt Service Routine.
IEC1bits.INT1IE = 1; // Enable INT1 Interrupt Service Routine.
IEC1bits.INT2IE = 1; // Enable INT2 Interrupt Service Routine.
// Set Interrupt Priority.
//IPC5bits.INT1IP = 5; // If all the IPC bits associated with
// an interrupt source are cleared, the interrupt
// source is effectively disabled.
//IPC7bits.INT2IP = 2; //set low priority
//IPC0bits.INT0IP = 2; //set low priority
IPC5bits.INT1IP = 4; /*set low priority*/
RPINR0bits.INT1R |= 24;//0x18; //001 1000; // Set Hall A - RPI24/RA8 set INT1
RPINR1bits.INT2R |= 51;//0x33; //011 0011 // Set Hall B = RPI51/RC3 set INT2
// Hall C RP39/RB7 is INT0 (not mappable)
I have verified with 100% certainty that the voltage on the pin is changing from 0 to 3.3V. Any help is appreciated.
Thanks,
Gary
Best Answer
At this point I feel fairly certain the problem was the line
which effectively disabled bit 15 (global interrupt enable). The following is a working initialization function.