ADC Peripheral Block Description
This block handles the ADC (Analog-to-Digital Converter) peripheral in STM32 microcontrollers. It enables the conversion of analog signals to digital, which is crucial for reading data from various sensors and external devices.

Table of Contents
Inputs
This block does not have any inputs.
Outputs
| Output Name | Type | Description |
|---|---|---|
| Channel N | uint16 | Digital value read from the ADC channel, where N represents the channel number. This value is scaled to the range of, in example, 0-4095 for a 12-bit ADC. The number and numbering of output channels depend on the Number of channels parameter. |
Block Parameters
Block Parameters for I2C
| Parameter | Description |
|---|---|
| ADC Number | The number of the ADC module. |
| Number of channels | The number of ADC channels to be read. This parameter determines the quantity of outputs for the ADC block. |
| Buffer size per channel [samples] | The number of samples stored in the buffer for each ADC channel. This setting allows the accumulation of multiple ADC readings, which can be useful for signal analysis or data filtering. |
| Sample time | The refresh period of the block’s outputs. This is not the ADC conversion time, which is set in the CubeMX configuration. |

CubeMX Configuration for a Given MCU Model
The CubeMX configuration and interface appearance may differ between individual MCU models within given families. Below are example CubeMX settings for selected MCU models. For other models, settings should be adjusted according to the manufacturer’s documentation and project requirements.
H7
CubeMX Settings
| No. | Name | Path | Setting | Description | Screenshot |
|---|---|---|---|---|---|
| 1 | Mode | Pinout & Configuration > ADC* > Mode > Channel | Differential orSingle-ended orChecked | Setting the ADC operating mode for the selected channel. Different channels can have different operating modes. Select all channels that are to be used in the ADC block. | ![]() |
| 2 | ADC Clock | Clock Configuration > ADC Clock Mux | Value depending on the target ADC frequency | Setting the clock source for the ADC interface. This value depends on the target ADC frequency and the system clock configuration. | ![]() |
| 3 | ADC Prescaler | Pinout & Configuration > ADC* > Parameter Settings > ADC_Settings > Clock Prescaler | Value depending on the target ADC frequency | Setting the prescaler for the ADC interface. This value depends on the target ADC frequency and the system clock configuration. | ![]() |
| 4 | Add DMA | Pinout & Configuration > ADC* > DMA Settings | Add | Adding DMA support for the ADC interface. | ![]() |
| 5 | Select ADC Module for DMA | Pinout & Configuration > ADC* > DMA Settings > DMA Request > Select | Selected ADC module, e.g., ADC1, ADC2 etc. | Selecting the ADC module used in the ADC block. | ![]() |
| 6 | DMA Mode | Pinout & Configuration > ADC* > DMA Settings > DMA Request Settings > DMA Mode | Circular | Setting the DMA operating mode. Circular mode allows continuous reading of data from the ADC and storing it in a buffer, which aligns with the operation of the ADC block. | ![]() |
| 7 | DMA Address and Data Width | Pinout & Configuration > ADC* > DMA Settings > DMA Request Settings > Increment Address and Data Width | MemoryHalf Word | Setting the data transfer direction and data width for DMA. The Memory direction means that data will be transferred from the ADC peripheral to memory, and the Half Word width means data will be transferred in 16-bit units. | ![]() |
| 8 | Continuous Conversion Mode | Pinout & Configuration > ADC* > Parameter Settings > ADC_Settings > Continuous Conversion Mode | Enabled | Enabling continuous conversion mode for the ADC interface. This mode allows uninterrupted data reading. | ![]() |
| 9 | Conversion Data Management Mode | Pinout & Configuration > ADC* > Parameter Settings > ADC_Settings > Conversion Data Management Mode | DMA Circular Mode | Setting the conversion data management mode for the ADC interface. DMA Circular mode allows continuous reading of data from the ADC and storing it in a buffer. | ![]() |
| 10 | End Of Conversion Selection | Pinout & Configuration > ADC* > Parameter Settings > ADC_Settings > End of Conversion Selection | End of single conversionor End of sequence conversion | Selecting the conversion completion condition for the ADC interface. | ![]() |
| 11 | Number of Conversion | Pinout & Configuration > ADC* > Parameter Settings > ADC_Regular_ConversionMode > Number of Conversion | Equal to the number of selected channels | The number of conversions to be performed in the ADC conversion sequence. This value should be equal to the number of channels selected for conversion. | ![]() |
| 12 | Rank | Pinout & Configuration > ADC* > Parameter Settings > ADC_Regular_ConversionMode > Rank | Appropriate for the desired sequence | The order in which the ADC channels will be converted within the conversion sequence. Each channel should be assigned a unique rank number that defines its position in the sequence. Select the appropriate channel. | ![]() |
| 13 | Sampling Time | Pinout & Configuration > ADC* > Parameter Settings > ADC_Regular_ConversionMode > Rank > Sampling Time | Calculated value | The duration (expressed in clock cycles) for which the ADC sampling capacitor charges from the selected channel before its conversion begins. | ![]() |
Calculating Sampling Time
Where:
- – ADC sampling time (in ADC clock cycles);
- – model step time (model sample time, expressed in seconds);
- – number of channels used;
- – number of samples per channel (Buffer size per channel parameter);
- – ADC clock frequency (expressed in Hz);
- – constant conversion time overhead (to be verified in the processor’s Reference Manual, typically around 10.5 to 12.5 cycles).
Important: It is recommended to set the sampling time to the highest possible value that satisfies the above condition. This provides a more stable reading and significantly reduces processor load.
Interrupts for the ADC are not mandatory.
ADC* - the asterisk (*) symbol represents the number of the ADC module used in the model, e.g., ADC1, ADC2 etc.
















