SPI output to MAX5741 DAC to wake up and generate a ramp on all outputs

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
DanArgust
Date:
Thu Jul 14 09:53:23 2016 +0000
Commit message:
First commit; SPI output to wake up a MAX5741 DAC and generate a ramp on all outputs

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	Thu Jul 14 09:53:23 2016 +0000
@@ -0,0 +1,34 @@
+/***************************
+* Controller for 10bit DAC *
+* MAX5741 Ramp Signal      *
+* 08/07/2016               *
+* Dan Argust               *
+***************************/
+
+#include "mbed.h"
+
+//SPI(MOSI,MISO,SCLK)
+SPI device(P0_9,P0_8,P1_29);
+DigitalOut cs(P0_2);
+
+int response = 0;
+unsigned int control = 0x0;
+unsigned int data = 0x000;
+
+int main() {
+    device.format(16,1);
+    control = 0xf;
+    data = 0xf010;
+    cs = 0;
+    response = device.write((control<<12)|(data));
+    cs = 1;
+    control = 0xc;
+    data = 0x000;
+    while(true){
+        cs = 0;
+        response = device.write((control<<12)|(data));
+        cs = 1;
+        (data>=0xffc) ? (data=0) : (data += 0x04);
+        wait_us(1);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jul 14 09:53:23 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file