2025-02-24 04:28 AM - edited 2025-02-24 04:49 AM
Hi all,
I have created a new project for the STM32U575RIT6 microcontroller using the attached .ioc file. On top of the auto-generated code, I have made the following modifications:
In main.c:
while (1)
{
uint32_t bits = 0;
uint16_t adc_value = 0;
uint16_t n_samples = 50;
do
{
// Start the conversion process
HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED);
HAL_ADC_Start(&hadc1);
HAL_Delay(10);
// Average value of nSamples
if (HAL_ADC_PollForConversion(&hadc1, 5000) == HAL_OK)
{
adc_value = (uint16_t) HAL_ADC_GetValue(&hadc1);
if (adc_value > 0)
{
bits += adc_value;
}
}
}
}while(bits == 0);
HAL_Delay(1000);
}
In stm32u5xx_hal_msp.c:
void HAL_MspInit(void)
{
/* USER CODE BEGIN MspInit 0 */
/* USER CODE END MspInit 0 */
__HAL_RCC_PWR_CLK_ENABLE();
/* System interrupt init*/
/* USER CODE BEGIN MspInit 1 */
HAL_PWREx_EnableVddA();
HAL_PWREx_EnableVddIO2();
/* USER CODE END MspInit 1 */
}
However, the ADC always reads 0. I have verified the following:
Has anyone experienced similar issues or have suggestions on how to resolve this? Any help or advice would be greatly appreciated.
Thank you in advance for your assistance.
2025-02-24 06:17 AM
> Has anyone experienced similar issues or have suggestions on how to resolve this?
You haven't actually described what your issue is. Only that it "doesn't work".
Calibration should only be called once.