Skip to main content
BSchm.6
Associate II
June 1, 2023
Solved

Fast ADC polling with STM32F466?

Hi,

I want to permanently sample ADC data with an ST32F466. Timing is not important, so the idea is to do that out of the main loop. So my idea is, whenever there is some time and whenever the main-loop reaches the related position in code, it reads out the related data register of the ADC and then uses it. When the ADC is not yet ready - no problem, the main-loop will try later when it reaches that position again.

When looking at the example ADC HAL code, this is what has to be done:

HAL_ADC_Start(&AdcHandle);
HAL_ADC_PollForConversion(&AdcHandle, 10) ;
if ((HAL_ADC_GetState(&AdcHandle) & HAL_ADC_STATE_EOC_REG) == HAL_ADC_STATE_EOC_REG)
{
 uhADCxConvertedValue = HAL_ADC_GetValue(&AdcHandle);
}

Now when looking into the code behind these functions, this is way too complex and time-consuming, even for the relaxed timing of my main-loop.

So my question: is there a way to set the ADC into a mode where

  • it permanently samples data from the related input once it has been initialised
  • writes the converted data into a register where the application can read it from
  • sets a "ready"-bit so that the main application can see there is a new value that can be read out of that data-register?

Thanks :)

This topic has been closed for replies.
waclawek.jan
waclawek.janBest answer
Super User
June 1, 2023

> ST32F466

Do you mean STM32F446?

> is there a way to set the ADC into a mode where

> a) it permanently samples data from the related input once it has been initialised

> b) writes the converted data into a register where the application can read it from

> c) sets a "ready"-bit so that the main application can see there is a new value that can be read out of that data-register?


_legacyfs_online_stmicro_images_0693W00000dJpP1QAK.pngJW

2 replies

waclawek.jan
waclawek.janBest answer
Super User
June 1, 2023

> ST32F466

Do you mean STM32F446?

> is there a way to set the ADC into a mode where

> a) it permanently samples data from the related input once it has been initialised

> b) writes the converted data into a register where the application can read it from

> c) sets a "ready"-bit so that the main application can see there is a new value that can be read out of that data-register?


_legacyfs_online_stmicro_images_0693W00000dJpP1QAK.pngJW

BSchm.6
BSchm.6Author
Associate II
June 1, 2023

Got it - thanks!