Go Down

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


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 ()
  adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST);
  NVIC_EnableIRQ (ADC_IRQn);               // enable ADC interrupt vector

  adc_enable_interrupt(ADC, ADC_IER_RXBUFF);

  ADC->ADC_RPR  =  (uint32_t)  inp[0];      // DMA buffer
  ADC->ADC_RNPR =  (uint32_t)  inp[1];      // next DMA buffer
  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);

(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.


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