Skip to main content
Killstreet30
Associate III
January 12, 2023
Solved

Doubt regarding potentiometer ADC Values on STM32 NUCLEO - L476RG.

  • January 12, 2023
  • 2 replies
  • 1171 views

Hello,

I have configured my circuit to have a potentiometer and have set up an ADC with continuous conversion mode but I am unable to get a varied output. It just gets stuck on one value even thought I change the value of the potentiometer. Please help

I have attached my code below.

MX_ADC1_Init();

 /* USER CODE BEGIN 2 */

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

  /* USER CODE END WHILE */

 HAL_ADC_PollForConversion(&hadc1,1000);

  readValue = HAL_ADC_GetValue(&hadc1);

  /* USER CODE BEGIN 3 */

 }

Thanks!

This topic has been closed for replies.
Best answer by Jaroslav JANOS

Hi @Killstreet30​,

please double check that you configure your ADC properly, incl. proper channel/pin. Anyway, your code is probably missing

HAL_ADC_Start(&hadc1)

which means your ADC is not even enabled.

BR,

Jaroslav

2 replies

Jaroslav JANOS
Jaroslav JANOSBest answer
ST Employee
January 12, 2023

Hi @Killstreet30​,

please double check that you configure your ADC properly, incl. proper channel/pin. Anyway, your code is probably missing

HAL_ADC_Start(&hadc1)

which means your ADC is not even enabled.

BR,

Jaroslav

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.
Killstreet30
Associate III
January 12, 2023

Thank you!