Using the Timer to test the maximum speed of the ADC and DAC

Dependencies:   mbed

Revision:
1:6bb2d13644e8
Parent:
0:23ff2f1bb142
--- a/main.cpp	Tue Mar 07 12:56:43 2017 +0000
+++ b/main.cpp	Wed Mar 27 10:45:24 2019 +0000
@@ -9,7 +9,7 @@
 int main() {
     float value = 0;
     unsigned short value2 = 0;
-    while(1) {
+    //while(1) {
         t.start();
         pc.printf("Hello World!\n\r");
         t.stop();
@@ -19,21 +19,40 @@
         wait(2);
         myled = 0;
         wait(2);
-        pc.printf("Testing ADC time!\n\r");
+        pc.printf("Testing ADC time with floats!\n\r");
+        t.reset();
+        t.start();
+        value = Ain;
+        //value2 = Ain.read_u16();
+        t.stop();
+        pc.printf("ADC took %f seconds when using floats\n", t.read());
+        wait(2);
+        myled = 0;
+        wait(2);
+        pc.printf("Testing ADC time using integers!\n\r");
         t.reset();
         t.start();
         //value = Ain;
         value2 = Ain.read_u16();
         t.stop();
-        pc.printf("ADC took %f seconds\n", t.read());
+        pc.printf("ADC took %f seconds when using integers\n", t.read());
         wait(2);
-        pc.printf("Testing DAC time!\n\r");
+        pc.printf("Testing DAC time suing floats!\n\r");
         t.reset();
         t.start();
         Aout =value;
         t.stop();
-        pc.printf("DAC took %f seconds\n", t.read());
+        pc.printf("DAC took %f seconds when using floats\n", t.read());
         wait(2);
+     
+        pc.printf("Testing DAC time suing integers!\n\r");
+        t.reset();
+        t.start();
+        Aout.write_u16(value2 << 6);
+        t.stop();
+        pc.printf("DAC took %f seconds when using integers\n", t.read());
+        wait(2);
+        while(1);
         
-    }
+    //}
 }