2

I know that the ADC on the Arduino Due has a clock speed from 1 MHz to 20 MHz. I have two questions: 1. What is the default clock speed when I run a sketch, and 2. How can I change it? (I am using Arduino 1.6.4.)

The reason why I want to slow down the ADC as much as possible is to obtain the maximum source impedance. Is this logic correct? (i.e., if I slow down the ADC in the arduino code to kHz values, then the source impedance will reach MΩ values?) enter image description here

0

You can change the prescaler (ADCSR register). Lowest scaler is 2, so it can never run at 20mHz. Also Atmel recommends a max ADC clock of 1MHz.

Arduino sets the ADC clock to 125 KHz (prescaler of 128)

So to match Arduino, you should select a prescaler of 8 ( set bits ADPS1 and ADPS0)

  • Interesting. Where may I find the ADCSR register? Also, what's the highest prescaler possible? The reason why I want to slow down the ADC as much as possible is to obtain the maximum source impedance. Is this logic correct? (i.e., if I slow down the ADC in the arduino code to kHz values, then the source impedance will reach MΩ values?) – David Roberts Jun 17 '15 at 20:55
  • 1
    @Gerben Are you sure that holds true for the Due (ARM) or just for an Uno/Mega/Leonardo (AVR) as ADCSR sounds suspiciously like an AVR register name and not like an ARM one. – Tom Carpenter Jun 17 '15 at 22:45
  • @David Look for system\libsam\include\adc.h, system\libsam\include\adc.c, and variants\arduino_due_x\variant.cpp in the IDE directory. I am not sure of the exact paths as I have 1.5.1, not 1.6.1 and they've probably changed since then. But the first two have all the access routines for the ARM ADCs. The final one shows how they have initialised it. You will notice they initialise it to ADC_FREQ_MAX which is defined in adc.h to be 20MHz. – Tom Carpenter Jun 17 '15 at 22:57
  • @TomCarpenter you are right. This doesn't work on the Due. ATMega only. – Gerben Jun 18 '15 at 15:23
0

The atod clock is set in the mode register. The clock is 42MHz/(PRESCAL#+1). One way of setting it is the use ADC->ADCMR = ADC_MR_PRESCAL(PRESCAL#), where PRESCAL# is some integer. These symbols are defined in component_adc.h in the Arduino source code. In the AVR data sheet, the recommended clock is MIN=1MHz, MAX=20 MHZ, corresponding to numbers between 41 and 1. Look in the data sheet, section 43.

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.