Introduction

Author: Ștefan Vlad, Microchip Technology Inc.

The Analog-to-Digital Converter (ADC) is a 12-bit Successive Approximation Register (SAR) with possibilities for differential and single-ended conversions. This peripheral is available on the AVR® DA MCU (AVR DA) microcontrollers.

This technical brief describes how the ADC module works on the AVR DA microcontrollers, and it covers the following use cases:
  • ADC Single Conversion:

    Initialize the ADC, start the conversion and wait until it is completed, and read the ADC result in a loop.

  • ADC Free-Running Conversion:

    Initialize the ADC, enable Free-Running mode, start the conversion and wait until it is completed, and read the ADC result in an infinite loop.

  • ADC Differential Conversion:

    Initialize the ADC, configure two pins for reading the differential voltage, start the conversion and wait until it is completed, and read the ADC result in an infinite loop.

  • ADC Sample Accumulator:

    Initialize the ADC, enable accumulation of 64 samples, start the conversion and wait until it is completed, and read the ADC result in a loop.

  • ADC Window Comparator:

    Initialize the ADC, set the conversion window comparator low threshold, enable the conversion Window mode, enable the Free-Running mode, start the conversion and wait until it is completed, and read the ADC result in an infinite loop. An LED is toggled on if the ADC result is below the set threshold.

  • ADC Event Triggered:

    Initialize the ADC, initialize the Real-Time Counter (RTC), configure the Event System (EVSYS) to trigger an ADC conversion on the RTC overflow. An LED is toggled on after each ADC conversion.

  • ADC Temperature Measurement:

    Initialize the ADC, select the internal reference, select the temperature sensor as input and acquire the data by running a 12-bit, right adjusted, single-ended conversion.

The ADC results for all examples will be transmitted through Universal Asynchronous Receiver-Transmitter (USART) and plotted using the Data Visualizer tool.

Note: The code examples were developed on AVR128DA48 Curiosity Nano. They are available on GitHub, supporting both Atmel Studio and MPLAB X Integrated Development Environment (IDE).