30.3.2 Basic Operation
The following steps are recommended to initialize and run the ADC in basic
operation:
- Enable the ADC by writing a
‘
1
’ to the ENABLE bit in the Control A (ADCn.CTRLA) register. - Configure the Prescaler (PRESC) bit field in the Control B (ADCn.CTRLB) register.
- Configure the Timebase (TIMEBASE) and Reference Select (REFSEL) bit fields in the Control C (ADCn.CTRLC) register.
- Configure the Sample Duration (SAMPDUR) bit field in the Control E (ADCn.CTRLE) register.
- Optional: Configure the number of samples to be accumulated by writing the Sample Accumulation Number Select (SAMPNUM) bit field in the Control F (ADCn.CTRLF) register.
- Optional: Enable the Free-Running
mode by writing a ‘
1
’ to the Free-Running (FREERUN) bit in the Control F register. - Configure a positive input by writing to the MUXPOS bit field in the Positive Input Multiplexer (ADCn.MUXPOS) register.
- Optional: Configure a negative input by writing to the MUXNEG bit field in the Negative Input Multiplexer (ADCn.MUXNEG) register.
- Optional: Select Differential ADC
conversion by writing a ‘
1
’ to the Differential (DIFF) bit in the Command (ADCn.COMMAND) register. - Configure the mode of operation for the ADC by writing to the MODE bit field in the Command register.
- Configure how an ADC conversion will start by writing to the START bit field in the Command register. If the IMMEDIATE command is written, a conversion will start immediately.
- Wait until the Result Ready (RESRDY)
bit in the Interrupt Flags (ADCn.INTFLAGS) register is ‘
1
’ before reading the updated Result (ADCn.RESULT) register.