Skip to main content
Asantos
Associate III
Nov 13, 2026 2:07 PM UTC
Question

STM32G5 ADC regular simultaneous + Injected simultaneous DMA problem

Hi,

On the STM32G4 I was able to configure ADC1 and ADC2 in Dual regular simultaneous + injected simultaneous mode using DMA in Circular mode, so that I only needed to configure the DMA for ADC1 (Master) and the data from the regular conversion of ADC1 and ADC2 were placed in a single 32-bit variable, with the most significant part containing the value of ADC2 and the least significant part with the value of ADC1.

When I try to do the same thing for the STM32G5, an error occurs in the configuration of ADC2, requiring me to configure the DMA for ADC2 as well. It doesn't make sense to use the ADC in dual mode if I have to use a DMA channel for each ADC. How can I modify the attached ioc2 file to make it work as I did for the STM32G4? And what code should I include in main.c to start DMA in circular mode using low level  library?

1 reply

Philippe Cherbonnel
ST Employee
Nov 16, 2026 8:25 PM UTC

Hello ​@Asantos,

CubeMX2 actually allows to configure ADC multimode with one DMA channel for both ADC instances (conversion data concatenated).

Thanks for your .ioc2 project attached: your configuration is correct.

By "an error occurs in the configuration of ADC2", you probably refer to warning message "Conversion data packing is relevant with data transfer by DMA: to be activated in DMA panel" (cf picture attached).
This is an issue, sorry for this inconvenience. It will be fixed in the next STM32G5 HAL pack release.

However, this warning is non-blocking: you can ignore this warning and generate the project.

CubeMX2 ADC multimode configuration with one DMA channel for both ADC instances (conversion data concatenated)


Then, example of application code for process of ADC multimode with one DMA channel:

  if (HAL_ADC_MM_Start(pADC_Master) != HAL_OK)
  {
    error_handler();
  }

  if (HAL_ADC_MM_Calibrate(pADC_Master) != HAL_OK)
  {
    error_handler();
  }

  if (HAL_ADC_MM_REG_StartConv_DMA_Opt(pADC_Master, (uint8_t *)adc_buffer_data, sizeof(adc_buffer_data), HAL_ADC_OPT_DMA_IT_HT) != HAL_OK)
  {
    error_handler();
  }

  ...
  usage of callbacks data transfer half/complete, data processing.
  ...

  if (HAL_ADC_MM_REG_StopConv_DMA(pADC_Master) != HAL_OK)
  {
    error_handler();
  }

  if (HAL_ADC_MM_Stop(pADC_Master) != HAL_OK)
  {
    error_handler();
  }

Note: an example is available for ADC multimode in another configuration: each ADC instances with its own DMA channel (data transfer in 2 buffers):
https://github.com/STMicroelectronics/STM32CubeG5/tree/main/examples/hal/adc/multimode_simultaneous_dma_multi_buffers

Best regards