time needed for analogRead()

Status
Not open for further replies.

floating.

Well-known member
Hi,

How much time is needed for an analogRead() on a Teensy 3.2 with default clock speed?

Is the reading blocking, or non-blocking?

TIA
 
Last edited:
It depends. put micros() around analogRead() and measure for yourself. Default is about 10 us with T3.2@96mhz. Use of analogReadResolution() and analogReadAveraging() will affect timings. You can do asynch/DMA reads with https://github.com/pedvide/ADC, the example programs have various timing results.
 
Just to add onto what manitou said. Most of my experience and data is with using Pedvide's ADC Library, but I have several notes on how Paul's stock library works. With a clock of 48/96Mhz the ADC Clock by default gets set to 12Mhz for all resolutions but 8bit(24MHz) when using analogRead(). With the ADC at 12MHz and no other settings changed it takes 1uS to sample the ADC and roughly 1.5uS to do conversion. But the default library and Pedvide's library sample the ADC 4 times and provide the average. Which gives the 10uS.

Depending on how you configure the ADC's you can get >700KSPS at 12bit. At that speed you pretty much have to use DMA or your micro spends all day just sampling.
Keep in mind the faster you sample the stronger your signal needs to be, so large resistor dividers will adversely affect your readings.
 
I just wanted to get a rough idea since some ADCs can take longer to convert than others, but 10 uS is more than fast enough for my purpose. I don't need to get many samples (not at this time), but I'm running in a fairly tight loop. I'm not planning oon changing resolution or averaging, just do a few analogRead. I'll take a look at the Pedvide library.
 
Status
Not open for further replies.
Back
Top