Skip to main content
Visitor II
June 11, 2026
Solved

How to configure ADC in dual mode with STM32CubeMx2?

  • June 11, 2026
  • 1 reply
  • 58 views

I have read the migration guide (Typical HAL ADC use cases for migration - HAL2 Migrator 1.0.0 documentation) as well as the article How to use ADC with STM32CubeMX2 | Community

In the HAL2 code, I found functions such as HAL_ADC_MM_SetConfig(), which suggests that ADC multimode/dual mode is supported by the HAL.

However, when using STM32CubeMX2 (not STM32CubeMX), I cannot find any option to configure ADC dual mode (e.g., ADC1 + ADC2).

My question is:

How can ADC dual mode be configured in STM32CubeMX2?

If ADC dual mode configuration is currently not supported by STM32CubeMX2, a short confirmation would be appreciated.

 

Thanks in advance for your help.

Best answer by Philippe Cherbonnel

Hello Michaela,
ADC multimode (dual mode) is supported by STM32CubeMX2 HAL drivers, but not yet by UI interface.
It will be available in release 2.2.0.
In the meantime, you can use multimode with:


1. In UI, configure both ADC instances targeted for multimode (typically, ADC1 and ADC2).
   It will generate configuration code (mx_adc1_init(), mx_adc2_init()).


2. In your application code, add multimode configuration:

  hal_adc_handle_t *p_hadc_multimode_master = mx_adc1_gethandle(); // or mx_adc1_init() if not already called
hal_adc_handle_t *p_hadc_multimode_slave = mx_adc2_gethandle(); // or mx_adc2_init() if not already called

/* Link ADC handles */
if (HAL_ADC_SetLinkNextHandle(p_hadc_multimode_master, p_hadc_multimode_slave) != HAL_OK)
{
return EXEC_STATUS_ERROR;
}

/* Multimode: configured by ADC master only */
adc_mm_config.mode = HAL_ADC_MM_DUAL_REG_INTERL;
adc_mm_config.reg_data_format = HAL_ADC_MM_REG_DATA_PACK_32_BITS;
adc_mm_config.reg_data_transfer_packing = HAL_ADC_MM_REG_DATA_TRANSFER_UNPACK;
adc_mm_config.interl_delay = HAL_ADC_MM_INTERL_DELAY_12CYCLES;

if (HAL_ADC_MM_SetConfig(p_hadc_multimode_master, &adc_mm_config) != HAL_OK)
{
return EXEC_STATUS_ERROR;
}

 

3. Continue with process code:
HAL_ADC_MM_Start(p_hadc_multimode_master);
HAL_ADC_MM_Calibrate(p_hadc_multimode_master);
HAL_ADC_MM_REG_StartConv_DMA(...)


Additionally, you can find an example of ADC multimode:
From https://dev.st.com/stm32-example-library, search "multimode_simultaneous_dma_multi_buffers":

https://github.com/STMicroelectronics/STM32CubeC5/tree/main/examples/hal/adc/multimode_simultaneous_dma_multi_buffers

 

Best regards
Philippe

1 reply

Philippe Cherbonnel
ST Employee
June 12, 2026

Hello Michaela,
ADC multimode (dual mode) is supported by STM32CubeMX2 HAL drivers, but not yet by UI interface.
It will be available in release 2.2.0.
In the meantime, you can use multimode with:


1. In UI, configure both ADC instances targeted for multimode (typically, ADC1 and ADC2).
   It will generate configuration code (mx_adc1_init(), mx_adc2_init()).


2. In your application code, add multimode configuration:

  hal_adc_handle_t *p_hadc_multimode_master = mx_adc1_gethandle(); // or mx_adc1_init() if not already called
hal_adc_handle_t *p_hadc_multimode_slave = mx_adc2_gethandle(); // or mx_adc2_init() if not already called

/* Link ADC handles */
if (HAL_ADC_SetLinkNextHandle(p_hadc_multimode_master, p_hadc_multimode_slave) != HAL_OK)
{
return EXEC_STATUS_ERROR;
}

/* Multimode: configured by ADC master only */
adc_mm_config.mode = HAL_ADC_MM_DUAL_REG_INTERL;
adc_mm_config.reg_data_format = HAL_ADC_MM_REG_DATA_PACK_32_BITS;
adc_mm_config.reg_data_transfer_packing = HAL_ADC_MM_REG_DATA_TRANSFER_UNPACK;
adc_mm_config.interl_delay = HAL_ADC_MM_INTERL_DELAY_12CYCLES;

if (HAL_ADC_MM_SetConfig(p_hadc_multimode_master, &adc_mm_config) != HAL_OK)
{
return EXEC_STATUS_ERROR;
}

 

3. Continue with process code:
HAL_ADC_MM_Start(p_hadc_multimode_master);
HAL_ADC_MM_Calibrate(p_hadc_multimode_master);
HAL_ADC_MM_REG_StartConv_DMA(...)


Additionally, you can find an example of ADC multimode:
From https://dev.st.com/stm32-example-library, search "multimode_simultaneous_dma_multi_buffers":

https://github.com/STMicroelectronics/STM32CubeC5/tree/main/examples/hal/adc/multimode_simultaneous_dma_multi_buffers

 

Best regards
Philippe