2025-06-19 9:50 AM
Hello ST experts,
Recently, I was developing a project with STM32H750I microcontroller, I faced a problem with ADC self-calibration HAL function (HAL_ADCEx_Calibration_Start)!
I configured ADC1 and ADC2 in dual simultaneous mode + DMA + Timer with synchronous clock mode for clock Prescaler for both ADCs for better synchronization. I executed self-calibration function for ADC1 and ADC2 individually before activating Timer and DMA. The problem was that the microcontroller cannot finish the process. I checked the process only for ADC1. It was okay for ADC1. When I checked the process only for ADC2, it did not work. Also, I checked if I change timer Prescaler to the asynchronized clock mode, the self-calibration function will work. On the other hand, I miss ADCs synchronization. Therefore, I have to use synchronous mode for Clock Prescaler. Have you faced this problem in your projects? Could you please help me in this issue?
2025-06-19 2:22 PM
It was okay for ADC1. When I checked the process only for ADC2, it did not work.
You have to be more specific in what you mean by "it did not work"?
Was it that HAL status was not HAL_OK or that it did not return?
2025-06-20 1:01 AM - edited 2025-06-20 1:15 AM
Hello Karl,
This is the part of my code:
if(HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET_LINEARITY, ADC_DIFFERENTIAL_ENDED)!= HAL_OK)
{
Error_Handler();
}
HAL_Delay(500);
if(HAL_ADCEx_Calibration_Start(&hadc2, ADC_CALIB_OFFSET_LINEARITY, ADC_DIFFERENTIAL_ENDED)!= HAL_OK)
{
Error_Handler();
}
HAL_Delay(500);
HAL_TIM_Base_Start(&htim3);
HAL_ADCEx_MultiModeStart_DMA(&hadc2, (uint32_t*) ADC_BUFFER, 6);
The microcontroller cannot continue and it seems it got in a infinite loop!
Could you please help me?
2025-06-20 1:34 AM
So why are you calling this twice?
if(HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET_LINEARITY, ADC_DIFFERENTIAL_ENDED)!= HAL_OK)
{
Error_Handler();
}
HAL_Delay(500);
if(HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET_LINEARITY, ADC_DIFFERENTIAL_ENDED)!= HAL_OK)
{
Error_Handler();
}
When you call HAL_ADCEx_Calibration_Start, it calls ADC_Disable.
In ADC_Disable, it's calling HAL_GetTick(). If the System tick isn't working, then it will be stuck forever. But you have to run the debugger and see if uwTick is incrementing or not during the while loop.
Are you running internal clock or external clock? Upload your IOC file so we can see your clock settings.
2025-06-20 5:27 AM - edited 2025-06-22 12:55 PM
Hello Karl,
Sorry...I have corrected the code but the problem is not solved!
if(HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET_LINEARITY, ADC_DIFFERENTIAL_ENDED)!= HAL_OK)
{
Error_Handler();
}
HAL_Delay(500);
if(HAL_ADCEx_Calibration_Start(&hadc2, ADC_CALIB_OFFSET_LINEARITY, ADC_DIFFERENTIAL_ENDED)!= HAL_OK)
{
Error_Handler();
}
HAL_Delay(500);
HAL_TIM_Base_Start(&htim3);
HAL_ADCEx_MultiModeStart_DMA(&hadc1, (uint32_t*) ADC_BUFFER, 6);
However, it works when I choose Asynchronous clock mode for ADC1 and ADC2 Clock Prescaler. Why?
I am using external resonator 25 MHz.
Could you please help me in this issue?