5.2 Example

The following code snippet shows an example on how to configure the High Priority Interrupt vector.

High Priority Interrupt configuration
// io.h includes the device header file with register and vector defines
#include <avr/io.h>
// interrupt.h contains the ISR related content
#include <avr/interrupt.h>

void high_priority_interrupt_example(void) {
    // Set the level 1 interrupt vector
	CPUINT.LVL1VEC = PORTA_PORT_vect_num;

    // Enable global interrupts
    sei();
}

ISR(PORTA_PORT_vect){
    // This interrupt will have level 1 priority
    // after the configuration in CPUINT.LVL1VEC.
    
    // Check if a level 0 ISR has been interrupted
    if (CPUINT.STATUS & CPUINT_LVL0EX_bm) {
    
    }
}