How to use an ADC peripheral to convert a single channel continuously, from a software start. 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 continuous conversion mode, from SW trigger.
Example execution: From the main program execution, a ADC software start is performed once, ADC group regular perform conversions of the selected channel successively automatically, indefinitely. Software polls for the first conversion completion, then retrieves at will (every second in this example) conversion data.
LED1 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:
ADC, analog digital converter, analog, conversion, voltage, channel, analog input
- ADC/ADC_ContinuousConversion_TriggerSW_Init/Inc/stm32c0xx_it.h Interrupt handlers header file
- ADC/ADC_ContinuousConversion_TriggerSW_Init/Inc/main.h Header for main.c module
- ADC/ADC_ContinuousConversion_TriggerSW_Init/Inc/stm32_assert.h Template file to include assert_failed function
- ADC/ADC_ContinuousConversion_TriggerSW_Init/Src/stm32c0xx_it.c Interrupt handlers
- ADC/ADC_ContinuousConversion_TriggerSW_Init/Src/main.c Main program
- ADC/ADC_ContinuousConversion_TriggerSW_Init/Src/system_stm32c0xx.c STM32C0xx system source file
This example runs on STM32C071RBTx devices.
This example has been tested with NUCLEO-C071RB board and can be easily tailored to any other supported device and development board.
In order to make the program work, you must do the following :