     delayMicroseconds(readPeriod);
 }
 
+void printTimedADCInfo(uint8_t adc_num, uint16_t *buffer, uint32_t &delta_time) {
+  uint32_t min_value = 0xffff;
+  uint32_t max_value = 0;
+  uint32_t sum = 0;
+  for (int i = 0; i < BUFFER_SIZE; i++) {
+    if (buffer[i] < min_value) min_value = buffer[i];
+    if (buffer[i] > max_value) max_value = buffer[i];
+    sum += buffer[i];
+  }
+  float average_value = (float)sum / BUFFER_SIZE; // get an average...
+  float sum_delta_sq = 0;
+  for (int i = 0; i < BUFFER_SIZE; i++) {
+    int delta_from_center = (int)buffer[i] - average_value;
+    sum_delta_sq += delta_from_center * delta_from_center;
+  }
+  int rms = sqrt(sum_delta_sq / BUFFER_SIZE);
+  Serial.printf("ADC:%d delta time:%d freq:%d - min:%d max:%d avg:%d rms:%d\n", adc_num,
+                delta_time, (1000 * BUFFER_SIZE) / delta_time,
+                min_value, max_value, (int)average_value, rms);
+
+  delta_time = 0;
+
+}
+
 // This function will be called with the desired frequency
 // start the measurement
 // in my low-res oscilloscope this function seems to take 1.5-2 us.

            Serial.println("Timer1 setup failed");
    }

    if(!buffer0->isEmpty()) { // read the values in the buffer
        Serial.print("Read pin 0: ");
        Serial.println(buffer0->read()*3.3/adc->adc0->getMaxValue());
        //Serial.println("New value!");
    }
    if(!buffer1->isEmpty()) { // read the values in the buffer
        Serial.print("Read pin 1: ");
        Serial.println(buffer1->read()*3.3/adc->adc0->getMaxValue());
        //Serial.println("New value!");
    }

    if (Serial.available()) {
        c = Serial.read();


    //digitalWriteFast(ledPin+2, !digitalReadFast(ledPin+2));

    #if defined(__IMXRT1062__)  // Teensy 4.0
        asm("DSB");
    #endif

}