Initialization

The following steps are recommended in order to initialize ADC operation:
  1. 1.Configure the resolution by writing to the Resolution Selection bit (RESSEL) in the Control A register (ADC.CTRLA).
  2. 2.Optional: Enable the Free-Running mode by writing a '1' to the Free-Running bit (FREERUN) in ADC.CTRLA.
  3. 3.Optional: Configure the number of samples to be accumulated per conversion by writing the Sample Accumulation Number Select bits (SAMPNUM) in the Control B register (ADC.CTRLB).
  4. 4.Configure a voltage reference by writing to the Reference Selection bit (REFSEL) in the Control C register (ADC.CTRLC). Default is the internal voltage reference of the device (VREF, as configured there).
  5. 5.Configure the CLK_ADC by writing to the Prescaler bit field (PRESC) in the Control C register (ADC.CTRLC).
  6. 6.Configure an input by writing to the MUXPOS bit field in the MUXPOS register (ADC.MUXPOS).
  7. 7.Optional: Enable Start Event input by writing a '1' to the Start Event Input bit (STARTEI) in the Event Control register (ADC.EVCTRL). Configure the Event System accordingly.
  8. 8.Enable the ADC by writing a '1' to the ENABLE bit in ADC.CTRLA.

Following these steps will initialize the ADC for basic measurements, which can be triggered by an event (if configured) or by writing a '1' to the Start Conversion bit (STCONV) in the Command register (ADC.COMMAND).