This code acts as the master controlling the slave actions, done using FRDM_KL_25Z

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
suhasini
Date:
Fri Jul 29 10:00:16 2016 +0000
Commit message:
Master code using FRDM board

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jul 29 10:00:16 2016 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+ 
+SPI spi(PTD2, PTD3, PTD1); // mosi, miso, sclk
+DigitalOut cs(PTD0);
+Serial pc(USBTX,USBRX);
+
+ 
+int main() {
+    pc.baud(115200);
+    // Chip must be deselected
+    cs = 1;
+
+    // Setup the spi for 8 bit data, high steady state clock,
+    // second edge capture, with a 1MHz clock rate
+    spi.format(8,1);
+    //spi.frequency(1000000);
+    spi.frequency(512000); //internal clock frequency of ADS1291
+ 
+    // Select the device by setting chip select low
+    cs = 0;
+ int v=0;
+    // Send 0x8f, the command to read the WHOAMI register
+    spi.write(0x8F);
+
+
+    // Send a dummy byte to receive the contents of the WHOAMI register
+    int whoami = spi.write(0x00);
+  //  printf("WHOAMI register = 0x%X\n", whoami);
+  while(1)
+  {
+      wait(1);
+      
+  spi.write(v);
+   pc.printf("read the data %d",v);
+  //led = !led;
+  if(v==255)
+  v=0;
+  else
+  v=v+1;
+}
+    // Deselect the device
+    cs = 1;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jul 29 10:00:16 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7e07b6fb45cf
\ No newline at end of file