Multiplex analog inputs ?

Hey guys…

I want to read the analog inputs from the arduino due one by one…for example 5000 values from A0 , then 5000 from A1 and so on…till A5…

Can u help me the realize that in my code ?

here is my code for just the channel A0 :

unsigned int data[5000];

void setup() {        
  Serial.begin(115200);  
  adc_init(ADC, SystemCoreClock, 21000000UL, ADC_STARTUP_FAST);
  ADC->ADC_MR |= 0x80;  //set free running mode on ADC
  ADC->ADC_CHER = 0x80; //enable ADC on pin A0
  analogReadResolution(8);
}

void loop() {

  unsigned int i;
 

  for(i=0;i<5000;i++){
    while((ADC->ADC_ISR & 0x80)==0); // wait for conversion
    data[i]=ADC->ADC_CDR[7]; //get values
  }
 

  for(i=0;i<5000;i++) {
    Serial.println(data[i]);
  }
  
delay(100);  
}

and I don’t now how I have to program it for the other channels :confused:

Thanks a lot.