2.5 Interrupts

The ADC features three separate interrupt vectors. When one of the interrupt conditions occurs, an interrupt flag is set, and the CPU is notified and pointed to the corresponding Interrupt Service Routine (ISR). The following table shows the available interrupt vectors for the ADC.

Table 2-1. Available Interrupt Vectors and Sources
NameVector DescriptionInterrupt FlagConditions
ERRORError interruptTRIGOVRA new conversion is triggered while one is ongoing
SAMPOVRA new conversion overwrites an unread sample in ADCn.SAMPLE
RESOVRA new conversion or accumulation overwrites an unread result in ADCn.RESULT
SAMPRDYSample Ready interruptSAMPRDYThe sample is available in ADCn.SAMPLE
WCMPAs defined by WINSRC and WINCM in ADCn.CTRLD
RESRDYResult Ready interruptRESRDYThe result is available in ADCn.RESULT
WCMPAs defined by WINSRC and WINCM in ADCn.CTRLD

An interrupt source is enabled or disabled by writing to the corresponding bit in the Interrupt Control (ADCn.INTCTRL) register as shown in the code snippet below.

ADC0.INTCTRL = ADC_RESRDY_bm; /* Enable Result Ready interrupt */

The interrupt flag is cleared by writing a '1' to the bit position in the Interrupt Flags (ADCn.INTFLAGS) register as shown in the code snippet below.

ADC0.INTFLAGS = ADC_RESRDY_bm; /* Clear Result Ready interrupt flag */ 

Interrupt flags SAMPRDY and RESRDY can also be cleared by reading respectively the ADCn.SAMPLE and ADCn.RESULT registers.