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:
where is the period of the ADC Clock ).
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, .\newline
Then, in Section 126.96.36.199 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,
- 12 bit mode,
with in ns and in ohms.
Two cases must be considered:
- The calculated tracking time is lower than . Set and in ADC\_MR.\newline In this case the allow can be computed versus the ADC frequency with the hypothesis that .
- The calculated tracking time is higher than . Set and 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 and the tracking time according to 43.6.10 is then one period of the ADC clock, . How is this reconciled with the fact that for case 1 the tracking time can be up to , 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 and . 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.