External interrupts on PIC24F16KL402 not working
Hi, I'm using the PIC24F16KL402 MCU to control and handle data from an accelerometer. I want to use the accelerometer interrupt signal to trigger the MCU to save the samples, but I'm not able to set up the external interrupts correctly. Right now I'm trying to make INT1 work, but I will need to use INT0 too.
I'm following the exact steps stated in the datasheet, but there must be something else I'm missing somewhere.
Here's the process:
1) Setting NSTDIS (I don't want nested interrupts).
2) I set the interrupt priority to 7 (INT1IP bits to 1).
3) I set the polarity to positive (INT1EP = 0).
4) Clear the interrupt flag (INT1IF = 0);
5) Enable interrupt (INT1IE = 1).
I also made sure to set the corresponding pins as inputs with the TRISB register.
Just to make sure I was setting everything up correctly, I send the contents of the registers through the UART to check out on the terminal, and this is what I got.
In the interrupt routine I just send a "1" character through the UART and clear the interrupt flag.
I'm using a cable connected to the INT1 pin and manually putting it to 1 and 0 logic value, and it never gets to trigger the interrupt as I never get to see the "1" character on the terminal.
What might be the problem?