2024-06-03 06:49 AM
I want to make 24 bit resolution adc reading from STM32H573I-DK starter kit. For this, after the documents I examined, I decided to configure ADC1 as master ADC2 as slave in dual regular conversion mode. However, when I run the code after making the necessary configurations in CUBE IDE, HAL_ADCEx_MultiModeConfigChannel(&hadc2, &multimode) != HAL_OK
I go to the error handler after the line. Although I created the cube from ide, it returns an error value from this line. When I look inside the function
ADC_MULTI_SLAVE(hadc, &tmp_hadc_slave);
line
if (tmp_hadc_slave.Instance == NULL)
I saw that it returned null in the If block. Adc2 does not seem to be a slave.
How can I solve this problem? I am waiting for your help. Thank you.
2024-06-03 08:36 AM - edited 2024-06-05 02:23 AM
Hello @Yandas
To configure dual ADC mode with 24-bit resolution on an STM32H5 series MCU using the STM32CubeIDE, you need to ensure that both ADCs are properly initialized and that the multi-mode configuration is set up correctly.
First of all, Configure ADC1 as the master and ADC2 as the slave in dual regular simultaneous mode. Ensure that both ADCs are activated and that the necessary GPIO pins for analog input are correctly configured. Configure the clock settings to provide the ADCs with the appropriate clock source and frequency.
Then, Before calling HAL_ADCEx_MultiModeConfigChannel(), make sure that both ADCs are ready to be configured in multi-mode. The multimode structure should be correctly filled with the desired multi-mode settings, including the mode selection that pairs ADC1 and ADC2.
PS: Could you please, Verify that you have not accidentally configured ADC2 to be used in a different mode that conflicts with the dual ADC mode.
However, Here's an example of how you might configure the multi-mode:
// Initialize both ADCs
MX_ADC1_Init();
MX_ADC2_Init();
// Define the multi-mode structure
ADC_MultiModeTypeDef multimode = {0};
multimode.Mode = ADC_DUALMODE_REGSIMULT;
multimode.DMAAccessMode = ADC_DMAACCESSMODE_DISABLED;
multimode.TwoSamplingDelay = ADC_TWOSAMPLINGDELAY_5CYCLES;
// Configure ADC1 as master and ADC2 as slave
if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
{
// Handle error for ADC1
Error_Handler();
}
// No need to call HAL_ADCEx_MultiModeConfigChannel for hadc2 since ADC1 is the master
If you continue to face issues, you may want to double-check the CubeMX configuration. It's also worth consulting the STM32H7 reference manual for more details on ADC multi-mode operation.
If the issue persist, Could you please provide more details on your setting project, if possible, attach your .ioc file/configuration.
2024-06-04 01:37 AM
Hello again @nouirakh ,
First of all, thank you for your interest.I still haven't solved the problem, I think there is an error in the dma settings. I have attached the full file for your review, thank you.