cancel
Showing results for 
Search instead for 
Did you mean: 

ADC not working for STM32u585 microcontroller

meghasb
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions

sure.

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

View solution in original post

7 REPLIES 7
RomainR.
ST Employee

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
Associate III

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

RomainR.
ST Employee

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.

yes its bad new..

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

  1. thnaku.. code is working now, with few changes in the configuration and of course by adding HAL_PWREx_EnableVddA();

RomainR.
ST Employee

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.

sure.

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