-2
\$\begingroup\$

Which operation a microcontroller can perform faster generally; to read a digital pin state or to take an ADC reading?

And how is the answer for my microcontroller Atmel SAM3X8E?

\$\endgroup\$
  • 4
    \$\begingroup\$ Generally, reading a digital input takes less time. For the specific answer for your controller, find the ADC section of the datasheet, and look for parameters for Conversion Time. This will frequently be specified in a number of clock cycles per conversion. \$\endgroup\$ – Lawrence NK1G Mar 6 '17 at 20:06
  • 1
    \$\begingroup\$ Digital readings are usually "immediate" or a few cycles while ADC takes much longer. \$\endgroup\$ – pjc50 Mar 6 '17 at 20:17
1
\$\begingroup\$

As Lawrence NK1G correctly pointed out, ADC is virtually always slower than a digital pin read. ADC requires several samples over a period of time to determine an analog voltage. This always takes multiple clock cycles. Reading a digital pin requires only one sample and take as few as one or two clock cycles depending on the microcontroller. According to this page http://asf.atmel.com/docs/3.21.0/sam3s/html/adc_use_case_1.html , the maximum ADC sample rate for your microcontroller is 1MHz. Compare that to this page https://forum.arduino.cc/index.php?topic=252690.0 which says that it should be possible to read a digital pin at 21MHz on the Arduino Due which uses the Atmel SAM3X8E.

\$\endgroup\$
  • \$\begingroup\$ You got a sense inversion :) ADC is always slower. I'm actually very hesitant to say "always" anything, because it invites someone to point out that "Frobotronic made the FT-6520551-AXZ which included a six-bit flash converter" . \$\endgroup\$ – Lawrence NK1G Mar 7 '17 at 1:49
  • \$\begingroup\$ I didn't mean to prompt you to change your text with that last change -- I suspect that there really isn't a uC with a built-in flash converter. I'm just pointing out one of my personal "Never say never, because the world is a very big place" foibles. \$\endgroup\$ – Lawrence NK1G Mar 7 '17 at 1:56
  • \$\begingroup\$ @LawrenceNK1G By the way, is the data sheet for Atmel SAM3X8E even available? Don't you need to buy a license since it's an ARM? Atmel doesn't have it on its website. \$\endgroup\$ – HaLailah HaZeh Mar 7 '17 at 1:58
  • \$\begingroup\$ I genuinely have no clue whatsoever. I've never designed anything around any of the ARM chips. \$\endgroup\$ – Lawrence NK1G Mar 7 '17 at 2:47
  • \$\begingroup\$ @HaLailahHaZeh You only need an ARM license if you want to make your own microcontroller. The datasheet is on Atmel's website. \$\endgroup\$ – duskwuff Mar 7 '17 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.