I'm trying to use the EXT INT1 and EXT_INT2 of PIC24FJ256GB110.
I'm using PPS in order to map these 2 interrupt to pin RD11 (RDP12) and RD10 (RP3).
I've followed the datasheet instruction by setting them as input in TRISD and then calling the proper ISR on a simple button press (rising edge), but it's not working..
Below the code...any errors?
Thank you for the advices.
Code: Select all
void EXT_INT1() iv IVT_ADDR_INT1INTERRUPT ics ICS_AUTO
{
switch_1 = 1;
IFS1.INT1IF =0; //Clear INT1
}
void EXT_INT2() iv IVT_ADDR_INT2INTERRUPT ics ICS_AUTO
{
switch_2 = 1;
IFS1.INT2IF =0; //Clear INT2
}
void main()
{
LATD = 0x00;
TRISD = 0x0C00; //RD11 , RD10 AS EXTERNAL INTERRUPT INPUT
Unlock_IOLOCK();
PPS_Mapping(12, _INPUT, _INT1); //pin 71 is PORTD.RD11 that has RP12--> assign ext INT 1
PPS_Mapping(3, _INPUT, _INT2); // pin 70 is PORTD.RD10 that has RP3--> assign ext INT 2
Lock_IOLOCK();
//1- Nested interrupt enabled
INTCON1.NSTDIS = 0;
INTCON2.INT1EP = 0; //rising edge
INTCON2.INT2EP = 0; //rising edge
INTCON2.ALTIVT = 0; //Disabled Alternate interrupt vector table
INTCON2.DISI = 0; //DISI function enabled to count the right amount of cycle with interrupt disabled
IPC5 = 0x0006; //priorita int 1 e 2
IPC7 = 0x0060;
IFS1.INT1IF =0; //Clear INT1
IFS1.INT1IE =1; //Enable external interrupt INT1
IFS1.INT2IF =0; //Clear INT2
IFS1.INT2IE =1; //Enable external interrupt INT2
while(1)
{
if(switch_1)
{
LED_ROSSO = 1;
Delay_ms(500);
LED_ROSSO = 0;
switch_1 = 0;
}
if(switch_2)
{
LED_VERDE = 1;
Delay_ms(500);
LED_VERDE = 0;
switch_2 = 0;
}
}