cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Polling for multiple channel not working

rahul7515
Associate III

i am trying to use multiple channel on a single ADC to measure certain voltages. what i have noticed is that let say i have selected 3 channels now in configuration of cube MX i select no of conversion to 3 and as soon as i do that Ranks get added below where i can select channel for each rank and choose that.

Code:

HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1,HAL_MAX_DELAY);
float voltage1 = HAL_ADC_GetValue(&hadc1)*(3.3/4096);
HAL_ADC_PollForConversion(&hadc1,HAL_MAX_DELAY);
float voltage2 = HAL_ADC_GetValue(&hadc1)*(3.3/4096);
HAL_ADC_PollForConversion(&hadc1,HAL_MAX_DELAY);
float voltage3 = HAL_ADC_GetValue(&hadc1)*(3.3/4096);

now when i run this code i get same output for all the conversion. the output is of the channel with rank 3. If i set the channel with rank 3 to ground i get output as 0 for all the conversion as is the channel with last rank is dominating over other. Is there something wrong in my configuration or the coding part.

PS: i am using STM32F103ZGT6 which has 12 bit ADC resolution

 

cube MX configuration:

Screenshot 2024-08-14 103128.png

0 REPLIES 0