2020-11-20 08:09 AM
Hi, I'm using STM32L4R5ZI nucleo board for my thesis project. But I have a problem doing a very easy thing: read an ADC conversion value. The program do just this: read the value and sends it over usart. The program does this:
HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
while (1)
{
HAL_ADC_Start(&hadc1);
if(HAL_ADC_PollForConversion(&hadc1, 1000) == HAL_OK){
raw = HAL_ADC_GetValue(&hadc1);
sprintf(msg, "%hu\r\n",raw);
}
else
sprintf(msg, "ERR\r\n");
HAL_UART_Transmit(&hlpuart1, msg, strlen(msg), HAL_MAX_DELAY);
HAL_Delay(1000);
}
I've done this with different boards and I've never had this problem. If I debug the program it is stucked in the HAL_ADC_PollForConversion function, in particular in this loop:
while ((hadc->Instance->ISR & tmp_Flag_End) == 0UL){
//...
}
This is my ADC configuration
Solved! Go to Solution.
2020-11-20 11:27 AM
I solved the problem changing the clock from asynchronous to synchronous. Maybe something went wrong in clock initialization. I can not understand what.
2020-11-20 11:27 AM
I solved the problem changing the clock from asynchronous to synchronous. Maybe something went wrong in clock initialization. I can not understand what.