Arduino ADC timing

While the ADC code shown previously works, I would like to understand it better; to understand how to correctly setup the Arduino ADC. Having looked at the datasheet for the Arduino processor (Atmel SAM3X8e) I am confused as the information given there seems inconsistent.

In Section 43.6.10 titled “ADC Timings” it states that:

“A minimal Tracking Time is necessary for the ADC to guarantee the best converted final value between two channel selections. This time has to be programmed through the TRACKTIM bit field in the Mode Register, ADC_MR.”

The tracking time is given by:

\displaystyle \frac{\rm{TRACKTIM}+1}{\rm{ADC\ Clock\ Frequency}} \mbox{\quad i.e.\quad } (\rm{TRACKTIM}+1)t_{CP\_ADC}

where {t_{CP\_ADC}} is the period of the ADC Clock {(1/(\rm{ADC\ Clock\ Frequency})}).

The TRACKTIM bit field has 4 bits and so takes values between 0 and 15. The tracking time therefore takes values between 1 and 16 times the ADC clock period, {t_{CP\_ADC}}.\newline

Then, in Section titled “Track and Hold Time versus Source Output Impedance” it says:

“During the tracking phase the ADC needs to track the input signal during the tracking times shown below:

  • 10 bit mode, {t_{track}=0.042 Z_{source}+160}
  • 12 bit mode, {t_{track}=0.054 Z_{source}+205}

with {t_{track}} in ns and {Z_{source}} in ohms.

Two cases must be considered:

  1. The calculated tracking time {t_{track}} is lower than {15 t_{CP\_ADC}}. Set {\rm{TRANSFER}=1} and {\rm{TRACKTIM}=0} in ADC\_MR.\newline In this case the allow {Z_{source}} can be computed versus the ADC frequency with the hypothesis that {t_{track}=15 t_{CP\_ADC}}.
  2. The calculated tracking time {t_{track}} is higher than {15 t_{CP\_ADC}}. Set {\rm{TRANSFER}=1} and {\rm{TRACKTIM}=0} in ADC_MR. In this case a timer will trigger the ADC in order to set the correct sampling rate according to the Track time.”

In the first case it says to set {\rm{TRACKTIM}=0} and the tracking time according to 43.6.10 is then one period of the ADC clock, {t_{CP\_ADC}}. How is this reconciled with the fact that for case 1 the tracking time can be up to {15 t_{CP\_ADC}}, while in case 2 it will be even higher still?

Looking at notes on the ADC implementation on a similar Atmel microcontroller (SAM3S) suggests the following:

  • In free-run mode the TRACKTIM and TRANSFER fields of the Mode Register are used to set the tracking and transfer timings. The tracking time needs to be set depending on the source impedance, but I still don’t understand what factors affect the transfer time.
  • In triggered mode set {\rm{TRACKTIM}=0} and {\rm{TRANSFER}=1}. Depending on the source impedance the details in the electrical characteristics section allow a tracking time to be calculated and this can then be used to calculate the sampling frequency. The sampling frequency should be between 0.05 and 1 MHz.

I will try to confirm this and report back.


This entry was posted in Arduino. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s