3.2 Example
Static Priority Interrupt scheme is the default setting for the interrupt controller in tinyAVR 0- and 1-series, and megaAVR 0-series devices, so the CPUINT registers are configured for this at startup. The following code snippet shows an example on how to configure the Static Priority Interrupt scheme.
Static Priority Interrupt scheme 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 static_priority_interrupt_example(void) { // If needed, clear the Round-robin Scheduling Enable bit. CPUINT.CTRLA &= ~CPUINT_LVL0RR_bm; // Example on how to shift the interrupt priority. CPUINT.LVL0PRI = PORTA_PORT_vect_num; // Enable global interrupts sei(); } ISR(PORTA_PORT_vect){ // This interrupt will have highest priority. }