This commit is contained in:
commit
eee3491124
1 changed files with 36 additions and 0 deletions
36
Fast ADC CH6 CH7
Normal file
36
Fast ADC CH6 CH7
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
unsigned long start_time;
|
||||
unsigned long stop_time;
|
||||
unsigned long values[2000];
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
REG_ADC_MR = 0x10380180; // change from 10380200 to 10380180, 1 is the PREESCALER and 8 means FREERUN
|
||||
ADC -> ADC_CHER = 0x03; // enable ADC on pin A0
|
||||
}
|
||||
|
||||
void loop() {
|
||||
unsigned int i;
|
||||
//reads in on pins 6 and 7
|
||||
|
||||
start_time = micros();
|
||||
for(i=0;i<1000;i++){
|
||||
while((ADC->ADC_ISR & 0x03)==0); // wait for conversion
|
||||
values[i]=ADC->ADC_CDR[0];
|
||||
values[i+1000]=ADC->ADC_CDR[1];//get values
|
||||
}
|
||||
stop_time = micros();
|
||||
|
||||
Serial.print("Total time: ");
|
||||
Serial.println(stop_time-start_time);
|
||||
Serial.print("Average time per conversion: ");
|
||||
Serial.println((float)(stop_time-start_time)/2000);
|
||||
|
||||
Serial.println("Values: ");
|
||||
for(i=0;i<1000;i++) {
|
||||
Serial.print(values[i]);
|
||||
Serial.print(", ");
|
||||
Serial.println(values[i+1000]);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
Loading…
Reference in a new issue