2.7 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 2-2. ADC Event Generators
Generator NameDescriptionEvent TypeGenerating Clock DomainLength of Event
PeripheralEvent
ADCnRESRDYResult readyPulseCLK_PEROne CLK_PER period
ADCnSAMPRDYSample readyPulseCLK_PEROne CLK_PER period
ADCnWCMPWindow compare matchPulseCLK_PEROne 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.
  • Event Generator: ADC0 RESRDY
  • Event USER: EVOUT (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-3. ADC Event Users and Available Event Actions
User NameDescriptionInput DetectionAsync/Sync
PeripheralEvent
ADCnSTARTADC start on eventEdgeAsync

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 */