Events

The ADC can be connected to the event system. The event system lets peripherals communicate without CPU intervention, enabling the CPU to perform other tasks or stay in a sleep mode. The ADC can be connected either as an event generator, providing signals to another peripheral, or an event user, performing tasks based on the signals from another peripheral.

The following table shows the different available event generators from the ADC.

Table 1. ADC Event Generators
Generator Name Description Event Type Generating Clock Domain Length of Event
Peripheral Event
ADCn RESRDY Result ready Pulse CLK_PER One CLK_PER period
ADCn SAMPRDY Sample ready Pulse CLK_PER One CLK_PER period
ADCn WCMP Window compare match Pulse CLK_PER One CLK_PER period
Below is a code snippet showing the configuration of event generator ADC0_RESRDY connected through event channel 1 to the EVOUT event user, which in this case outputs the event to PB2.
EVSYS.CHANNEL1 = EVSYS_CHANNEL1_ADC0_RES_gc;    /* ADC Result Ready */
EVSYS.USEREVSYSEVOUTB = EVSYS_USER_CHANNEL1_gc; /* Asynchronous Event Channel 1 */

The ADC has one event user for detecting and acting upon input events. The table below describes the event user and the associated functionality.

Table 2. ADC Event Users and Available Event Actions
User Name Description Input Detection Async/Sync
Peripheral Event
ADCn START ADC start on event Edge Async

The START event action can be triggered if the EVENT_TRIGGER setting is written to the START bit field in the Command (ADCn.COMMAND) register as shown in the code snippet below.

ADC0.COMMAND = ADC_START_EVENT_TRIGGER_gc;
Below is a code snippet showing the configuration of ADC0_START as an event user, reacting to RTC overflow.
EVSYS.CHANNEL0 = EVSYS_CHANNEL0_RTC_OVF_gc;   /* Real Time Counter overflow */
EVSYS.USERADC0START = EVSYS_USER_CHANNEL0_gc; /* Asynchronous Event Channel 0 */