Go Down

Topic: ADC configuration for AC0 : distort AC1 readings (Read 207 times) previous topic - next topic

leo2001

Hi !

I have started a project with the SplitRadixReal FFT library (https://coolarduino.wordpress.com/2014/09/25/splitradixreal-fft-library/). This library works perfectly.
To work correctly the arduino needs as many readings (on pin AC0) as possible, so the sketch needs to play with ADC features. This is the reason of my issue :
The readings are correct on pin AC0, but the readings on the other analog pins (ACx) are distorted.
I can't anderstand why, but the adc setup function seems to be the problem :

Code: [Select]
void adc_setup ()
{
  pmc_enable_periph_clk(ID_ADC);
  adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST);
  NVIC_EnableIRQ (ADC_IRQn);               // enable ADC interrupt vector

  adc_disable_all_channel(ADC);
  adc_enable_interrupt(ADC, ADC_IER_RXBUFF);

  ADC->ADC_RPR  =  (uint32_t)  inp[0];      // DMA buffer
  ADC->ADC_RCR  =  INP_BUFF;
  ADC->ADC_RNPR =  (uint32_t)  inp[1];      // next DMA buffer
  ADC->ADC_RNCR =  INP_BUFF;
  ADC->ADC_PTCR =  1;

  adc_set_bias_current(ADC, 0x01);
  adc_enable_channel(ADC, ADC_CHANNEL_7);  // AN0
  adc_configure_trigger(ADC, ADC_TRIG_TIO_CH_0, 0);
  adc_start(ADC);
}

(if disabled, the arduino's readings on AC1 are correct)

Do you know how to configure ADC to make sure it only impacts AC0 ?
Or to disable the ADC setup in the loop function ?


Thank you.

dougcl

I found that I had to use ADC_FREQ_MIN instead of ADC_FREQ_MAX. All of the analog inputs are processed by a single ADC within the Due, so if you are trying to use more than one channel, you have to allow settling time for the ADC to avoid channel crosstalk.

You can call the setup functions again within your Arduino sketch to override the Arduino initialization.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy