STM32L071 reading multiple ADC channels
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-15 3: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.
- Labels:
-
ADC
-
STM32CubeMX
-
STM32L0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-20 8: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 ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-21 2: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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-21 4:54 AM
then I show you how use this func. For() before while mark required channels...once
After this in while do job.
Selecting channels after start ADC is error... Check HAL returned values!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-21 5:26 AM
Thanks

- « Previous
-
- 1
- 2
- Next »