Getting Started with STM32H5 ARM Cortex M33: ADC Single Channel Continuous Conversion

In this guide on STM32H5, we shall configure the ADC of the STM32H5 to acquire analog voltage using polling mode in continuous mode.

In this guide, we shall cover the following:

  • Single vs continuous conversion.
  • Modification to STM32CubeMX.
  • Modification to the source code.
  • Results.

1. Single vs Continuous Conversion:

In STM32 microcontrollers, Analog-to-Digital Converters (ADC) can operate in single conversion or continuous conversion modes, each serving different purposes based on the application requirements.

1. Single Conversion Mode

Operation: In single conversion mode, the ADC performs a single conversion of the selected channel(s) and then stops. Once the conversion is complete, the ADC goes idle until it’s triggered again (either manually by software or by an external trigger).

Use Case: This mode is ideal for applications that require occasional sampling, like reading sensor values at specific intervals. It’s useful when the system needs precise control over when conversions happen and avoids unnecessary power consumption.

Power Efficiency: Since the ADC is only active during the conversion, single conversion mode is more power-efficient for low-frequency measurements.

2. Continuous Conversion Mode

Operation: In continuous conversion mode, the ADC repeatedly converts the selected channel(s) without stopping. As soon as one conversion is complete, another conversion starts automatically.

Use Case: This mode is beneficial for real-time monitoring applications where continuous sampling is needed, such as audio signal processing, data acquisition systems, or control systems that need frequent updates.

Data Handling: Continuous mode generates an ongoing stream of data, so it often requires efficient handling, like using DMA (Direct Memory Access) to transfer data to memory without CPU intervention, which improves performance in time-sensitive applications.

Key Differences

Aspect Single Conversion Mode Continuous Conversion Mode

Conversion Trigger Manually triggered or by an external event Starts automatically after each conversion

Power Consumption Lower, as ADC is idle between triggers Higher, as ADC is always active

Data Handling Easier, no need for constant reading May require DMA to manage continuous data

Use Cases Intermittent measurements Real-time or continuous data acquisition

Choosing Between the Two

• Use single conversion mode when you need control over when the ADC operates, conserving power, or if you only need periodic data.

• Use continuous conversion mode for applications where constant monitoring is critical and fast data handling is set up (like with DMA).

2. Modification to STM32CubeMX:

From the left side in project, open adc_single.ioc file as following:

Then from ADC section, parameter settings, enable the continuous mode as following:

Thats all for the configuration. Save the project and that will generate the new configuration.

3. Modification to the Source Code:

move the following function from the while 1 loop to user code begin 2:

HAL_ADC_Start(&hadc1);

In continuous mode, we need only to launch the ADC once and it will take over.

That all for the guide.

Save, build and run the project on your STM32H563Zi Nucleo-144 as following:

4. Results:

Open your serial terminal application, set the baud rate 115200 and you should get the following:

Happy coding 😉

Add Comment

Your email address will not be published. Required fields are marked *