John La / Mbed 2 deprecated MCP3208_STM32

Dependencies:   MCP3208_SWSPI SWSPI mbed

Fork of MCP3208_STM32 by Michael Chuah

Files at this revision

API Documentation at this revision

Comitter:
mcx
Date:
Wed Nov 16 23:47:52 2016 +0000
Parent:
3:1701a3738c54
Child:
5:9568cfe486dd
Commit message:
Working;

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	Thu Nov 12 22:12:34 2015 +0000
+++ b/main.cpp	Wed Nov 16 23:47:52 2016 +0000
@@ -9,6 +9,7 @@
 // Serial pc(USBTX, USBRX);
 
 Ticker datalog;
+Timer t;
 
 char datastr0[5];
 char datastr1[5];
@@ -17,6 +18,8 @@
 char datastr4[5];
 char datastr5[5];
 
+char datastr6[5];
+
 // Credit: Erik Olieman
 // http://developer.mbed.org/questions/5149/Serial-port-on-LPC1114-is-slow/
 void intToString(char *buffer, int value)
@@ -50,10 +53,13 @@
 
 int main()
 {
-    pc.baud(921600);
+    int tt = 0;
+    t.start();
+
+    pc.baud(9600);
     pc.printf("Working!!\n\r");
 
-    datalog.attach_us(&log_data,1000); // 1000us = 1ms
+    datalog.attach_us(&log_data,1000000); // 1000us = 1ms
 
     while(1) {
         intToString(datastr0,input1.binary(0));
@@ -63,10 +69,19 @@
         intToString(datastr4,input1.binary(4));
         intToString(datastr5,input1.binary(5));
 
+        // Timing methods to verify 1 ms loop time / 1 kHz update speed
+        // tt = t.read_ms();
+        tt++;
+        if(tt>=10000) {
+            tt = 0;
+        }
+        intToString(datastr6,tt);
+
         if(tickerActivated == true) {
             tickerActivated = false;
             pc.printf("%s,%s,%s,%s,%s,%s\n\r",datastr0,datastr1,datastr2,datastr3,datastr4,datastr5);
         }
+
     }
 }
 
--- a/mbed.bld	Thu Nov 12 22:12:34 2015 +0000
+++ b/mbed.bld	Wed Nov 16 23:47:52 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file