ADC_MultiChannelSingleConversion Example Description

How to use an ADC peripheral to convert several channels. ADC conversions are performed successively in a scan sequence. This example is based on the STM32C0xx ADC HAL API.

Example configuration:

Example execution:

Every second, ADC performs conversion of a channel among the 3 channels of the scan sequence, successively at each conversion start (discontinuous mode enabled).

Note: In case of discontinuous mode is disabled, then the entire scan sequence is converted in burst from one conversion start.

ADC conversion data of each sequence rank is transferred by DMA into the array “uhADCxConvertedData”:

When sequence is completed, it restarts from the beginning: first channel in the sequence, data transfer in first array address (rollback).

ADC conversions raw data are computed to physical values using LL ADC driver helper macro:

Note: For this example purpose, analog reference voltage (Vref+) is computed from ADC conversion of internal voltage reference VrefInt and used to compute other conversion data. This voltage should correspond to value of literal “VDDA_APPLI”. This procedure can be performed when value of voltage Vref+ is unknown in the application. (This is not the case in this example due to target board supplied by a LDO regulator providing a known constant voltage of value “VDDA_APPLI”). In typical case of Vref+ connected to Vdd, it allows to deduce Vdd value.

LED4 is used to monitor program execution status:

Debug: variables to monitor with debugger:

Connection needed:

Use an external power supply to generate a voltage in range [0V; 3.3V] and connect it to analog input pin (cf pin below).

Note: If no power supply available, this pin can be let floating (in this case ADC conversion data will be undetermined).

Other peripherals used:

1 GPIO for LED4

1 GPIO for analog input: ADC channel 4 on pin PA.04 (Arduino connector CN8 pin 3 A2, Morpho connector CN7 pin 32)

1 DMA channel

Keywords

ADC, analog digital converter, analog, conversion, voltage, channel, analog input, DMA transfer, sequence, temperature sensor, internal voltage reference, VrefInt, discontinuous

Directory contents

Hardware and Software environment

How to use it ?

In order to make the program work, you must do the following :