Skip to main content
ferraridamiano
Associate II
November 20, 2020
Solved

STM32L4R5ZI stucked on polling for adc conversion

  • November 20, 2020
  • 1 reply
  • 742 views

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

0693W000005C9fvQAC.jpg 

This topic has been closed for replies.
Best answer by ferraridamiano

I solved the problem changing the clock from asynchronous to synchronous. Maybe something went wrong in clock initialization. I can not understand what.

1 reply

ferraridamiano
ferraridamianoAuthorBest answer
Associate II
November 20, 2020

I solved the problem changing the clock from asynchronous to synchronous. Maybe something went wrong in clock initialization. I can not understand what.