2016-08-10 08: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
2016-08-10 08:45 AM
Most STM32 parts expect the use of DMA when scanning ADC channels.
2016-08-10 08:58 AM
So... I can not use the scan mode with polling?
2016-08-10 09: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.pdf2016-08-10 09:40 AM
I dont understand...
This should work.Why do I get timeout errors?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
2016-08-10 10:33 AM
OK.
I get it ... I was thinking about the scan mode differently.I will try to use DMA ...