TTT / Mbed 2 deprecated DDS_Playground

Dependencies:   mbed

Revision:
5:4ef14f22e7b1
Parent:
4:42262a293f60
Child:
6:b9a883bb1d63
diff -r 42262a293f60 -r 4ef14f22e7b1 main.cpp
--- a/main.cpp	Thu Apr 16 19:21:35 2015 +0000
+++ b/main.cpp	Fri Apr 17 01:10:41 2015 +0000
@@ -171,87 +171,39 @@
     //init spi
     SPI_AFE_ADC_AND_DDS.format(16,2);
     SPI_AFE_ADC_AND_DDS.frequency(33000000);
-    
+ /*   
     //make sure SPI is setup to mode 2, MSB first
     //init DDS
     begin();
     //output calculation
     //fOut = fMCLK / 2^28 * FREQREG = 50e6 / 2^28 * FREQREG
     //FREQREG = fOut * 2^28 / 50e6 = fOut * 5.36870912
-    //1 MHz: 5368709, 2 MHz: 10737418, 3 MHz: 16106127, 4 MHz: 21474836, 8 MHz: 42949673 MHz, 20 MHz: 107374182, Max: 0x3FFF
-    setFrequencyWord(0, 5368709); // 500K
+    //100K: 536870, 1 MHz: 5368709, 2 MHz: 10737418, 3 MHz: 16106127, 4 MHz: 21474836, 8 MHz: 42949673 MHz, 20 MHz: 107374182, Max: 0x3FFF
+    setFrequencyWord(0, 536870); // 500K
     setFrequencyWord(1, 0x3FFF);
     selectFrequency(0);
               
-    setSignOutput(SIGN_OUTPUT_NONE); //set SIGN BIT OUT to Z
-    setOutputMode(OUTPUT_MODE_SINE); 
-    DDS = 1;
+//    setSignOutput(SIGN_OUTPUT_NONE); //set SIGN BIT OUT to Z
+//    setOutputMode(OUTPUT_MODE_SINE); 
+//    DDS = 1;
     
-/*    // FOR A SQUARE WAVE:
+    // FOR A SQUARE WAVE:
     setSignOutput(SIGN_OUTPUT_MSB);
     //open the DDS output
     SQUARE = 1;
-*/    
-//    SQUARE = 0;
-//    DDS = 1;
-/*     
-    int i;
-    float frequencies[] = {100,50,33,25,20,17,14,12,11,10,9,8};
     
-    while(1) {
-        for( i=0; i< sizeof(frequencies)/sizeof(float); i++) {
-            setFrequencyWord(0, (int)((float)(2<<27) / frequencies[i]));
-            selectFrequency(0);
-            wait_ms(2000);
-            LED_3 = !LED_3;
-        }
-        wait_ms(3000);
-    }
 
-    #define bit_up_time 8 //8 for no logic
-    #define bit_guard_time 8 //8 for no logic
-    #define data_reset_time 16 //16 for no logic
-        
-    //specify the data
-    #define data_len 9 //in bytes, remember to leave the last byte as 0 for the crc
-    uint8_t data[data_len] = {0xAA, 0xFF, 0xD0, 0x59, 0xE4, 0xCC, 0x1A, 0x2A, 0}; //bt mac format: header, type, data ... data, crc (crc should be 0x89 in this case)
-    data[data_len-1] = Crc8(&data[1], data_len-2); //crc includes everything except the header byte
-    uint8_t bytecount = 0, bitcount = 0;
-    int32_t freq = 0;
-    uint8_t freqRegister = 0;
-*/    
-/*    
-    __disable_irq(); 
-    while(1) {
-        for (bytecount=0; bytecount<data_len; bytecount++){
-            for(bitcount=0; bitcount<8; bitcount++){
-                if ( (( data[bytecount]>>bitcount ) & 0x01) == 0){ //send binary 0
-                    
-                    selectFrequency(0);
-                    SQUARE = 1;
-                    
-                    wait_ms(bit_up_time);
-                    
-                    SQUARE = 0;
-                    //set_DDS(DDS_MCLK_SLEEP); //THIS CAUSES PROBLEMS - ENVELOPE ON DATA?
-                    wait_ms(bit_guard_time);
-                    
-                } else { //send binary 1
-                    selectFrequency(1);
-                    SQUARE = 1;
-                    
-                    wait_ms(bit_up_time);
-                    
-                    SQUARE = 0;
-                    //set_DDS(DDS_MCLK_SLEEP); //THIS CAUSES PROBLEMS - ENVELOPE ON DATA?
-                    wait_ms(bit_guard_time);
-                }
-            }//end bitcount
-        }//end bytecount
-        
-        wait_ms(data_reset_time); //all the data has been sent, delay for some time to reset
-        
-    }//end while
-    __enable_irq();  
-*/    
+    int32_t freq = 10737418;
+ */ 
+    
+    while(1) 
+    {  
+        writeReg(0x2100);
+        writeReg(0x50C7);
+        writeReg(0x4000);
+        writeReg(0xC000);
+        writeReg(0x2000);
+    
+        wait_ms(1000);
+    }
 }