Problem with polling ADC scan mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-08-10 8:26 AM
Hello.
I have some troubles with ADC scan mode... For example:while (1)
{
uint32_t adc;
HAL_StatusTypeDef err;
HAL_ADC_Start(&hadc1);
for (int i = 0; i < 9; i++)
{
err = HAL_ADC_PollForConversion(&hadc1, 1000);
if (err != HAL_OK)
HAL_Delay(50);
adc = (uint16_t) HAL_ADC_GetValue(&hadc1);
#if (TEST_PRINTS_ADC == 1)
memset(TEST_PRINT, 0, TEST_LENGHT);
sprintf(TEST_PRINT, ''ADC CH%d - %5lu\r\n'', i, adc);
HAL_UART_Transmit(&huart3, (uint8_t*)TEST_PRINT, strlen(TEST_PRINT), 1000);
#endif
}
HAL_ADC_Stop(&hadc1);
}
All pins are configured and ordered in scan rank.
In result I have 2 good convertions and the following gives timeout error.
Does anyone have any clue what might be happening?
https://postimg.org/image/v2rv4661n/
Thank you.
#adc #single-scan #!stm32
- Labels:
-
ADC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-08-10 8:45 AM
Most STM32 parts expect the use of DMA when scanning ADC channels.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-08-10 8:58 AM
So... I can not use the scan mode with polling?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-08-10 9:22 AM
It is strange to me can not do the scan with polling....
1.2 Multichannel (scan), single conversion modehttp://www.st.com/content/ccc/resource/technical/document/application_note/c4/63/a9/f4/ae/f2/48/5d/CD00258017.pdf/files/CD00258017.pdf/jcr:content/translations/en.CD00258017.pdf- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-08-10 9:40 AM
I dont understand...
This should work.Why do I get timeout errors?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-08-10 10:14 AM
So... I can not use the scan mode with polling?
You can try, I'm trying to save you wasting your time.It is strange to me can not do the scan with polling.... Seems strange to me that people burn 100's of cycles spinning in do-nothing loops too, but to each their own.Why do I get timeout errors? You spend 1000's of cycles outputting to a USART for conversions that take a dozen or so cycles a piece. I think the ADC has out run you. The scan method is designed around having DMA fill an array with a complete set of conversions and giving you a TC signal in place of a dozen EOCs
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-08-10 10:33 AM
OK.
I get it ... I was thinking about the scan mode differently.I will try to use DMA ...