33.3.3.5 Conversion Result (Output Formats)

The result of an analog-to-digital conversion is written to the 16-bit Result (ADCn.RES) register and is given by the following equations:

Single-ended 12-bit conversion: R E S = V A I N P V A D C R E F × 4096 [ 0 , 4095 ]

Single-ended 10-bit conversion: R E S = V A I N P V A D C R E F × 1024 [ 0 , 1023 ]

Differential 12-bit conversion: R E S = V A I N P V A I N N V A D C R E F × 2048 [ -2048 , 2047 ]

Differential 10-bit conversion: R E S = V A I N P V A I N N V A D C R E F × 512 [ -512 , 511 ]

where VAINP and VAINN are the positive and negative ADC inputs and VADCREF is the selected ADC voltage reference.

The data format used for single-ended conversions is unsigned one’s complement, while two's complement with sign extension is used for differential conversions. Consequently, for differential conversions the sign bit is padded to the higher bits in the Result register, if needed.

By default, conversion results are stored in the Result register as right-adjusted 16-bit values. The eight Least Significant bits (LSbs) are then located in the low byte of the Result register. By writing a ‘1’ to the Left Adjust Result (LEFTADJ) bit in the Control A (ADCn.CTRLA) register, the values will be left-adjusted by placing the eight Most Significant bits (MSbs) in the high byte of the Result register.

The two figures below illustrate the relationship between the analog input and the corresponding ADC output.

Figure 33-8. Unsigned Single-Ended, Input Range, and Result Representation

Where VAINP is the single-ended or internal input.

Figure 33-9. Signed Differential Input, Input Range, and Result Representation

If a single-ended analog input is above the ADC voltage reference level, the 12-bit ADC result will be 0xFFF (decimal 4095). Likewise, if the input is below 0V, the ADC result will be 0x000.

If the voltage difference between VAINP and VAINN for a 12-bit differential conversion is above the ADC voltage reference level, the ADC result will be 0x7FF (decimal 2047). If the voltage difference is larger than the voltage reference level in the negative direction, the ADC result will be 0x800 (decimal -2048).