Sampling frequency (Arduino DUE)

Hello!

Is there an easy way to set the sampling frequency of the analogread( ) function or by any other mean (via interrupt, timer... ) ?
We're trying to acquire 4 analog signals at the specific sampling frequency of 2kHz.

Thanks for your help.

GBM4900_202:
Is there an easy way to set the sampling frequency of the analogread( ) function or by any other mean (via interrupt, timer... ) ?
We're trying to acquire 4 analog signals at the specific sampling frequency of 2kHz.

Thanks for your help.

Hi there,
Yes it is. But if you are only in need of 2kHz samples I think the default rate is enough for you since it samples at around 8.620 samples per second. That means that the analogread() takes about 116?s to be done.

However DUE has a 12 bit ADC downscaled by software at 10bits to fit other arduinos.
If you still want to know more about changing the sampling frequency here is a paper that you may find handy.
http://www.marulaberry.co.za/index.php/tutorials/code/arduino-adc/

Bare in mind that DUE does not use a 16MHz clock and calculations with other arduinos may differ.

You might want to see this example which drives ADC at 48kHz: Example of driving ADC and DAC from timer for regular sampling - Arduino Due - Arduino Forum
(The datasheet is required reading for programming at this level!)