6.1 Initialize the ADC

This subsection presents how to initialize the ADC module to run in Differential Conversion mode. This application uses the Config B setup explained in Hardware Configuration.

The ADC Differential Conversion mode is enabled by setting the CONVMODE bit in the ADC0.CTRLA register:

Figure 6-1. ADC0.CTRLA - Set the CONVMODE Bit

This translates into the following code:

ADC0.CTRLA |= ADC_CONVMODE_bm; 

For the Differential Conversion, the Pot click is connected to PD3 (AIN3) and the Pot 2 click is connected to PD4 (AIN4) pins of the AVR DA device.

Figure 6-2. MUX Selection for Negative ADC Input
ADC0.MUXNEG = ADC_MUXNEG_AIN4_gc;

Then, the ADC results can be read in a while loop.