cancel
Showing results for 
Search instead for 
Did you mean: 

Use of ADC

Jad
Associate III

good morning everyone,

i am trying to use the ADC of the stm32h745 disco. for that i connected my ADC to a breadboard with a potentiometer. I wanted to change the value of the potentiometer so i can see on my computer the values. I got inspired by this video: https://www.youtube.com/watch?v=EsZLgqhqfO0. unfortunately, it did not give the values that i want. as you can see, the values where moving between 2000 and 3000 and did not change when i changed the resistance of the potentiometer, even when i disconected directly the wires from the breadboard:

Jad_0-1729257934007.png

 

here is my code :

HAL_ADC_Start(&hadc3);
 HAL_ADC_PollForConversion(&hadc3,1000);
 raw= HAL_ADC_GetValue(&hadc3);
 // convert to string out of raw value
 sprintf(msg,"%hu\r\n",raw);
 HAL_UART_Transmit(&huart1, (uint8_t*)msg, strlen(msg), 1000);
 HAL_Delay(1);

I think it might be a problem of my ADC allocation: in fact, i connected it to ADC 3 at pinPF10 because it was one of the only one I could find in the manual. How do we get the other channels?

Capture d’écran 2024-10-15 à 17.39.25.png

Jad_0-1729258070043.png

Jad_1-1729258164197.jpeg

in the picture, my potentiometer had a max of 5kohm and not 50kohm

Best regards

1 ACCEPTED SOLUTION

Accepted Solutions

@Jad wrote:

What do you mean by ADC calibration enabling?


Please have a look at the RM0399 section 26.4.8 Calibration (ADCAL, ADCALDIF, ADCALLIN, ADC_CALFACT)

The example I provided to you is enabling the ADC calibration.

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.

View solution in original post

4 REPLIES 4
SofLit
ST Employee

Hello @Jad ,

Did you double check the board schematics and check if that ADC input is not connected to something else on the board?

Did you enable the ADC calibration?

You can also inspire from this example on STM32H743I-EVAL: regular conversion with polling using a potientiometer.

Hope it helps.

PS: Please use </> button to paste your code. See the tips on posting.

 

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

Thank you for the example, I will examine it precisely.

Those were the only other functions of pf10 that I found. What do you mean by ADC calibration enabling? Do you mean enabeling adc3 global interrupt ? because i did not enable it.

Capture d’écran 2024-10-19 à 09.24.21.png

Capture d’écran 2024-10-19 à 09.23.32.png

Jad
Associate III

i got my error, another channel was put in priority 1, so i desabled it. it works now but i do not know how to know theoretically the max/min digital values and the difference between them in term of voltage


@Jad wrote:

What do you mean by ADC calibration enabling?


Please have a look at the RM0399 section 26.4.8 Calibration (ADCAL, ADCALDIF, ADCALLIN, ADC_CALFACT)

The example I provided to you is enabling the ADC calibration.

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.