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