Class for AD7390, a 12 bit SPI driven external DAC from Analog Devices.

Dependencies:   mbed

Datasheet - http://www.analog.com/static/imported-files/data_sheets/AD7390_7391.pdf

Revision:
0:82cd70f9fc3f
Child:
2:8633e348822f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Apr 05 19:08:44 2014 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+
+SPI DAC(p5, p6, p7);                //mosi, miso, sclck
+DigitalOut CLR (p10);               //Resets DAC register to 0 when pulled low
+DigitalOut LD (p8);                 //Pull low to load DAC register from shift register
+DigitalOut led(LED2);
+
+int main()
+{
+        DAC.format(12,0);               //Set to 12 bit data transfer with no change in clock polarity or phase
+        DAC.frequency(2000000);
+
+    while(1) {
+
+        CLR = 1;                    //Pull this low to set back to 0;
+        LD = 1;                     //Send high as the DAC register is loaded once pulled low.
+        DAC.write(0x3ff);           //Write 256 to DAC
+        LD = 0;                     //Send to DAC register from shift register
+        wait_us(10);                //Give time to update
+        LD = 1;                     //Send back into read mode
+        wait(2);
+        DAC.write(0xBff);           //Write 256 to DAC
+        LD = 0;                     //Send to DAC register from shift register
+        wait_us(10);                //Give time to update
+        LD = 1; 
+        wait(2); 
+
+
+    }
+}