commit 9a04526a46a9b56187a587ad239f78c5e2d2252c Author: James Devine Date: Sat Aug 22 22:19:16 2015 +0200 diff --git a/Cosmic Pi 1MSPS readout test b/Cosmic Pi 1MSPS readout test new file mode 100644 index 0000000..678714b --- /dev/null +++ b/Cosmic Pi 1MSPS readout test @@ -0,0 +1,79 @@ + + +int x; // read value +int adcloopctr; +unsigned long values[100]; +const int eventtrigger = 49; +boolean eventhappened = false; +int sampledepth = 10; +int printctr = 0; +int readoutctr; + +void setup() +{ +// analogReference(INTERNAL); + pinMode(eventtrigger, INPUT); +attachInterrupt(eventtrigger, monkey, FALLING); + Serial.begin(115200); // initialize the serial port: + REG_ADC_MR = 0x10380180; // change from 10380200 to 10380180, 1 is the PREESCALER and 8 means FREERUN + ADC -> ADC_CHER = 0x80; // enable ADC on pin A0 +eventhappened = false; +adcloopctr=0; +Serial.println("Alive"); +} + +void loop() { + + //unsigned long t = micros(); // init time an elapsed time, in micro seconds + + //for(i = 0; i < 1000; i++) { + + // instrucction to measure + while((ADC->ADC_ISR & 0x80)==0); // wait for conversion + values[adcloopctr] = ADC->ADC_CDR[7]; // read value A0 + + + + +if (eventhappened){ + //Serial.println("Event"); + //for (int printctr = adcloopctr+1; printctr+1 < sampledepth+adcloopctr; printctr++) { + //Serial.print(printctr); + //Serial.print(", "); + //if (printctr > sampledepth){ + //Serial.println(values[(printctr)]); + //Serial.println(values[(printctr)]); + //} + //printctr = ++printctr % sampledepth; +readoutctr=10; + for (int firsthalf=adcloopctr+1; firsthalf