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

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tgartlan
Date:
Wed Mar 27 10:45:24 2019 +0000
Parent:
0:23ff2f1bb142
Commit message:
Using the timer to test the speed of the ADC and DAC first usingfloats, then using integers. ADC looks to be 10 times slower than DAC.; Not sure if experiment is good since no real difference between float and interger for ADC. Time is 20us for both

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- 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);
         
-    }
+    //}
 }
--- a/mbed.bld	Tue Mar 07 12:56:43 2017 +0000
+++ b/mbed.bld	Wed Mar 27 10:45:24 2019 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file