Getting started with ADC

Revision as of 12:52, 11 January 2023 by Registered User
Under construction.png Coming soon

This article explains what is ADC and how to use it through examples.

1. What is an analog to digital converter (ADC)?

The analog-to-digital converters allows the microcontroller to accept an analog value like a sensor output and convert the signal into the digital domain. In this article, we focus on the STM32L4 ADC.

1.1. Simplified block diagram

The figure below shows the general block diagram for each analog-to-digital converters embedded in the STM32L4. ADC block diagram .png

1.2. ADC features in STM32L4x6 products

ADC units Up to 3 modules
Input channel Up to 24 external channels (GPIOs), single/differential
Technology 12-bit successive approximation
Conversion time 188 nS, 5.33 Msamples/s (when fADC_CLK = 80 MHz)
Functional mode Single, Continuous, Scan, Discontinuous, or Injected
Triggers Software or external trigger (for Timers & IOs)
Special functions Hardware oversampling, analog watchdogs
Data processing Interrupt generation, DMA requests
Low-power modes Deep power-down, auto delay, power consumption dependent on speed
  • High performance features
    • Supports up to 5.33 mega samples per second of conversion which could be extended to 10Msamples/s (devices with dual ADC).
    • Includes the oversampling hardware which accumulates data and then divides it without CPU.
    • Flexible sequencer
    • Auto-calibration to reduce offset
  • Low Power features
    • Deep power-down mode
    • Auto-delayed conversion
    • Power consumption depends on sampling time
  • Conversion Speeds
    • ADC needs minimum 2.5ADC_CLKs for sample period and 12.5ADC_CLKs for conversion (12-bit).
    • 80 MHz maximum clock with a 15 cycle results in 5.33 Msamples/s
    • Speed up by low resolution
  • Programmable sampling time
  • Flexible clock selection


1.3. ADC Conversion Modes

AD converter supports several conversion modes: Single mode, which converts only one channel, in single-shot or continuous mode. Scan mode, which converts a complete set of pre-defined programmed input channels, in single-shot or continuous mode. Discontinuous mode, converts only a single channel at each trigger signal from the list of pre-defined programmed input channels.

ADC conversion modes.png
There are several functional modes which will be explained in details in the Reference Manual.

2. Configuring ADC to measure the DAC

2.1. Objectives

  • Learning how to set up the ADC with DMA in STM32CubeMX.
  • Generating code in STM32CubeMX and using HAL functions.
  • Creating a simple application to start the ADC and measure the DAC.

2.2. Create the project in STM32CubeMX


[[category:Getting_started_with_STM32_system_peripherals | 70]]