9.1 Initialize the ADC

An ADC conversion can also be triggered by an event, which is enabled by writing a ‘1’ to the Start Event Input (STARTEI) bit in the Event Control (ADCn.EVCTRL) register (ADC0 instance will be used in this example).

The ADC Event Triggered use case is based on the Config A setup explained in Hardware Configuration.

Figure 9-1. ADC0.EVTRL - Enable the STARTEI Bit

The following line of code enables the ADC to be triggered by a rising edge event:

ADC0.EVCTRL |= ADC_STARTEI_bm;

Any incoming event routed to the ADC through the Event System (EVSYS) will trigger an ADC conversion. The event trigger input is edge sensitive. When an event occurs, STCONV in ADCn.COMMAND is set, and STCONV will be cleared when the conversion is complete.

For example, the following settings must be made to start the ADC conversion on the RTC overflow:

  1. The RTC overflow event must be linked to channel 0 of the Event System.
  2. The Event User ADC0 must be configured to take its input from channel 0.
  3. The STARTEI bit in the ADC0.EVCTRL register of the ADC must be set to allow the ADC conversion to be triggered by the events.
EVSYS.CHANNEL0 = EVSYS_GENERATOR_RTC_OVF_gc; /* Real Time Counter overflow */
EVSYS.USERADC0 = EVSYS_CHANNEL_CHANNEL0_gc; /* Connect user to event channel 0 */
ADC0.EVCTRL |= ADC_STARTEI_bm; /* Enable event triggered conversion */