5 Interrupt on VDDIO2 Status

When the state of the VDDIO2 Status bit changes, the VDDIO2 interrupt flag will be raised. To be able to catch this interrupt immediately, it is necessary to enable both the VDDIO2 interrupt and global interrupts in general.

Figure 5-1. MVIO.INTCTRL - Enable the VDDIO2 Interrupt

/*Enable the VDDIO2 interrupt*/
MVIO.INTCTRL |= MVIO_VDDIO2IE_bm; 
/*Enable Global interrupts*/
sei();

The MVIO vector will be called when the interrupt is triggered. Before returning from the Interrupt Service Routine (ISR), the VDDIO2 (VDDIO2IF) interrupt flag in the MVIO Interrupt Flags (MVIO.INTFLAGS) register must be cleared. This is done by writing a ‘1’ to the flag.

Figure 5-2. MVIO.INTFLAGS - Clear VDDIO2 Interrupt Flag

ISR(MVIO_MVIO_vect)
{
    /* The VDDIO2 interrupt has been triggered */
    LED0_toggle();
    /* Clear the CFD interrupt flag */
    MVIO.INTFLAGS |= MVIO_VDDIO2IF_bm;
}