Skip to main content
meghasb
Associate III
January 4, 2023
Solved

ADC not working for STM32u585 microcontroller

hi, im working on ADC, but ADC is not working, it is getting into infinite loop in this stage  while ((hadc->Instance->ISR & tmp_flag_end) == 0UL)

and my code follows like this

HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_SET);

   // get ADC value

   HAL_ADC_Start(&hadc1);

   HAL_ADC_PollForConversion(&hadc1, HAL_MAX_DELAY);

   raw = HAL_ADC_GetValue(&hadc1);

   HAL_ADC_Stop(&hadc1);

   HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_RESET);

   HAL_Delay(1000);

  data= (float)(5*raw/4095);

  uint8_t length= sprintf(msg, "%.3lf\r\n\0", data);

  HAL_UART_Transmit(&huart1, msg, length, 100);

it is getting stuck in ADC poll for conversion. UART is working perfectly fine.

changed the frequency, checked by changing with channels and different ADC bits. and no option for changing to synchronous, its working on async.

This topic has been closed for replies.
meghasb
meghasbBest answer
Associate III
January 5, 2023

sure.

0693W00000Y7TSiQAN.pngthese are the configuration need to take care while designing.

7 replies

RomainR.
ST Employee
January 4, 2023

Hello meghasb (Community Member)

The STM32U5 family has an internal switch on the VDDA, it is necessary to activate it by software.

Check this question if it helps you:

https://community.st.com/s/question/0D53W00001XwdhxSAB/how-to-enable-adc1-on-nucleou575ziq

Best regards,

Romain,

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
meghasb
meghasbAuthor
Associate III
January 4, 2023

@RomainR.​ thanku.. but no luck,, not working.. is their anything i have to enable

RomainR.
ST Employee
January 4, 2023

Bad news. 

Are you using a custom board  ?

Are the product pins VDDA, VREF+, VSSA and VREF- correctly supplied?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
meghasb
meghasbAuthor
Associate III
January 5, 2023

yes its bad new..

no not custom board, yes all pins correctly supplied..

RomainR.
ST Employee
January 5, 2023

Hello meghasb (Community Member)

Good thing you were able to find a solution.

It would be useful for the community if you could explain what you have changed in your code ?

Best regards,

Romain

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
meghasb
meghasbAuthorBest answer
Associate III
January 5, 2023

sure.

0693W00000Y7TSiQAN.pngthese are the configuration need to take care while designing.