cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4R5ZI stucked on polling for adc conversion

ferraridamiano
Associate II

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 

1 ACCEPTED SOLUTION

Accepted Solutions
ferraridamiano
Associate II

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

View solution in original post

1 REPLY 1
ferraridamiano
Associate II

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