2022-04-15 03:36 AM
Hello. We chose STM32L071 CPU without realising that it does not have Scan conversion mode for multiple ADC channels.
Can someone confirm if it is possible to read multiple ADC channels using this CPU?
Please suggest what is the most convenient way to do this.
2022-04-20 08:30 AM
I dont test but try
for(int i = 0; i< Max_Channels; i++) select_adc_channel(i);
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_ADC_Start(&hadc);
for(int i = 0; i< Max_Channels; i++)
{
HAL_ADC_PollForConversion(&hadc, HAL_MAX_DELAY);
adcValue[i] = HAL_ADC_GetValue(&hadc);
printf("adc value[%i]=%u \n",i,adcValue[i]);
}
printf("\n");
HAL_Delay(1000);
}
if continuos enabled then too start adc move before while ...
2022-04-21 02:18 AM
Thanks for the response. I dont understand the code. Why would you want to call select_adc_channel(i); outside a for loop where the adc conversion happens? If I understand it correctly, before you step into while loop, you will simply call select_adc_channel multiple times and do nothing else. Shouldnt it be:
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_ADC_Start(&hadc);
for(int i = 0; i< Max_Channels; i++)
{
select_adc_channel(i);
HAL_ADC_PollForConversion(&hadc, HAL_MAX_DELAY);
adcValue[i] = HAL_ADC_GetValue(&hadc);
printf("adc value[%i]=%u \n",i,adcValue[i]);
}
printf("\n");
HAL_Delay(1000);
}
2022-04-21 04:54 AM
2022-04-21 05:26 AM
Thanks