ADC_SingleConversion_TriggerSW_Init Example Description

How to use ADC to convert a single channel at each SW start, conversion performed using programming model: polling. This example is based on the STM32C0xx ADC LL API. The peripheral initialization is done using LL unitary service functions for optimization purposes (performance and size).

Example configuration:

ADC is configured to convert a single channel, in single conversion mode, from SW trigger.

Example execution:

From the main program execution, a ADC software start is performed every second, ADC group regular converts the selected channel. Software polls for conversion completion. When conversion is completed, program reads conversion data from ADC data register and stores it into a variable.

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)

Keywords

ADC, analog digital converter, analog, conversion, voltage, channel, analog input

Directory contents

Hardware and Software environment

How to use it ?

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