This tutorial shows how to use various modes of the STM32 ADCs, including:

Basic single-channel measurement

Use of interrupts

DMA

Multi-channel sequences

Before you begin, install VisualGDB 5.0 or later and ensure you are using the latest version of the STM32 BSP.

An ADC (Analog-to-Digital Converter) is a peripheral that allows measuring the voltage (between 0 and V ref ) on a certain input of the microcontroller and converting it into a number between 0 and 2N-1 where N is the ADC resolution. The easiest way to experiment with an ADC is to connect it to a potentiometer – a mechanically adjustable resistor: If you connect one of the side terminals of the potentiometer to the GND pin on your board and the other one to the VCC pin, rotating the potentiometer knob will gradually change the voltage level (relative to ground) on the third pin between 0 and VDD, that should produce values from 0 to 4095 for a 12-bit ADC.

In this tutorial we will use the STM32F4Discovery board with the STM32F407VG microcontroller that has several ADC inputs. We will use the PC1 pin connected to channel 11 of ADCs 1-3 according to the STM32F407xx datasheet: The connected potentiometer will look like this: Now we will start writing the software to experiment with different ADC modes.