2024-01-19 10:28 PM - last edited on 2024-09-24 05:18 AM by Amel NASRI
Hi everyone,
I am trying to use multichannel ADC. I have a panel and an ntc for which I have to read the voltage vlaues. I have disabled the continuous conversion.
sConfig.Channel = ADC_CHANNEL_0; // Select channel for NTC
sConfig.Rank = 1;
sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
HAL_ADC_ConfigChannel(&hadc, &sConfig);
HAL_ADC_Start(&hadc);
HAL_ADC_PollForConversion(&hadc, 2000);
uint32_t ntc = HAL_ADC_GetValue(&hadc);
HAL_ADC_Stop(&hadc);
Even after selecting channel I get value of channel 0 in channel and if i dont select any channel then i get the same channel 0 value in channel one. I also tried not selecting channel 0 and only selecting channel 1 then in first run after restart i get channel 0 value in channel 0 and channel 1 value in channel 1 but since I have selected channel 1 and this code is in while loop i get channel 1 value in channel 0 in the continuous rus. Can anyone please help me out..
Solved! Go to Solution.
2024-01-19 11:45 PM
Hi this worked for me
HAL_ADC_Start(&hadc);
HAL_ADC_PollForConversion(&hadc, 1000); //Poll for NTC
uint32_t ntc = HAL_ADC_GetValue(&hadc);
HAL_ADC_PollForConversion(&hadc, 1000); //Poll for solar panel
uint32_t sol_vltg = HAL_ADC_GetValue(&hadc);
HAL_ADC_Stop(&hadc);
2024-01-19 11:45 PM
Hi this worked for me
HAL_ADC_Start(&hadc);
HAL_ADC_PollForConversion(&hadc, 1000); //Poll for NTC
uint32_t ntc = HAL_ADC_GetValue(&hadc);
HAL_ADC_PollForConversion(&hadc, 1000); //Poll for solar panel
uint32_t sol_vltg = HAL_ADC_GetValue(&hadc);
HAL_ADC_Stop(&hadc);