Initialization

The following steps are recommended to initialize ADC operation:
  1. 1.Configure the ADC voltage reference in the Voltage Reference (VREF) peripheral.
  2. 2.Optional: Select between Single-Ended or Differential mode by writing to the Conversion Mode (CONVMODE) bit in the Control A (ADCn.CTRLA) register.
  3. 3.Configure the resolution by writing to the Resolution Selection (RESSEL) bit field in the ADCn.CTRLA register.
  4. 4.Optional: Configure to left adjust by writing a ‘1’ to the Left Adjust Result (LEFTADJ) bit in the ADCn.CTRLA register.
  5. 5.Optional: Select the Free-Running mode by writing a ‘1’ to the Free-Running (FREERUN) bit in the ADCn.CTRLA register.
  6. 6.Optional: Configure the number of samples to be accumulated per conversion by writing to the Sample Accumulation Number Select (SAMPNUM) bit field in the Control B (ADCn.CTRLB) register.
  7. 7.Configure the ADC clock (CLK_ADC) by writing to the Prescaler (PRESC) bit field in the Control C (ADCn.CTRLC) register.
  8. 8.Select the positive ADC input by writing to the MUXPOS bit field in the ADCn.MUXPOS register.
  9. 9.Optional: Select the negative ADC input by writing to the MUXNEG bit field in the ADCn.MUXNEG register.
  10. 10.Optional: Enable Start Event input by writing a ‘1’ to the Start Event Input (STARTEI) bit in the Event Control (ADCn.EVCTRL) register, and configure the Event System accordingly.
  11. 11.Enable the ADC by writing a ‘1’ to the ADC Enable (ENABLE) bit in the ADCn.CTRLA register.

Following these steps will initialize the ADC for basic measurements.

For details about the start-up time of the VREF peripheral, refer to the Electrical Characteristics section.

The ADC does not consume power when the ENABLE bit is ‘0’. The ADC generates a 10- or 12-bit result which can be read from the Result (ADCn.RES) register.

Notes: Changing the following registers during a conversion will give unpredictable results: