Josh Jennings / Mbed 2 deprecated Instrumentation

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
joshthepirate
Date:
Fri Jan 31 15:55:14 2020 +0000
Parent:
1:a22687a74345
Commit message:
removed pow

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Jan 31 15:14:42 2020 +0000
+++ b/main.cpp	Fri Jan 31 15:55:14 2020 +0000
@@ -21,6 +21,8 @@
 void WriteRegister(short dat) {
     fsyncpin = 0;                   // Set FSYNC low before writing to AD9833 registers
     
+    // printf("writing register with %i.\r\n");
+    
     wait_us(10);                    // Give AD9833 time to get ready to receive data.
                                     
     spi.write(dat >> 8);         // Each AD9833 register is 32 bits wide and each 16
@@ -35,7 +37,9 @@
 
 void AD9833setFrequency(long frequency, int Waveform) {
     
-  long FreqWord = (frequency * pow(2, 28.0)) / refFreq;
+  long FreqWord = (frequency * 0x1000000) / refFreq;
+  
+  printf("freq word: %ld\r\n", FreqWord);
   
   int MSB = (int)((FreqWord & 0xFFFC000) >> 14);    //Only lower 14 bits are used for data
   int LSB = (int)(FreqWord & 0x3FFF);
@@ -52,8 +56,9 @@
 }
 
 void setup() {
-    spi.format(16, 2); // set to 16 bit data and mode 2
-    spi.frequency(freq); // set initial fequency
+    fssyncpin = 1;
+    spi.format(8, 2); // set to 16 bit data and mode 2
+    spi.frequency(1000000); // set initial fequency
     
     AD9833reset();                                   // Reset AD9833 module after power-up.