In avr Xmega device, there are only two IO port interrupt vectors INT0 and INT1.
I have three switches that should generate three interrupts. I have written an interrupt code for the first switch using INT0. Now, I can write the second interrupt using INT1 which will exhaust my vectors. Below is my code for INT0 ISR:
ISR (PORTD_INT0_vect){
PORTD.INTFLAGS = 0x01; // clear INT0IF flag.
PORTD_OUT = PORTD_OUT | (1<<4); // led on.
}
Can I redefine this ISR to enable interrupt for second switch?
The registers that I set in main function are as follows:
PORTD.INT0MASK = 0x04; // PD2 is the source of interrupt for INT0.
PORTD.INTCTRL = 0x03; // Disable INT1, enable INT0 and place it a high-priority level.
PORTD.PIN2CTRL = 0x03; // configure PD2 pin to interrupt on the low level of signal.
PMIC.CTRL = 0x07; // enable high,medium, and low level interrupts.
sei(); // enable interrupt globally.