DDS AD9854, library to configure a AD9854 Serial Interface (SPI)

Dependents:   JRO_DDSv2 JRO_DDSv2_rev2019

Files at this revision

API Documentation at this revision

Comitter:
miguelcordero191
Date:
Wed Sep 04 22:26:24 2019 +0000
Parent:
0:156a9e15919e
Commit message:
04/09/2019

Changed in this revision

AD9854.cpp Show annotated file Show diff for this revision Revisions of this file
AD9854.h Show annotated file Show diff for this revision Revisions of this file
diff -r 156a9e15919e -r d81fca2297fb AD9854.cpp
--- a/AD9854.cpp	Tue Feb 24 20:08:13 2015 +0000
+++ b/AD9854.cpp	Wed Sep 04 22:26:24 2019 +0000
@@ -2,15 +2,9 @@
 
 static char controlRegister[4];
 static char read_spi_data[6];
-
-static char* KO_MSG = "KO";
-static char* OK_MSG = "OK";
-static char* NI_MSG = "NI";
+static char message[0x32];
 
-static char* ZERO_MSG = "\x00";
-static char* ONE_MSG = "\x01";
-
-static char *MODULATION[6] = {"None         ", "FSK          ", "Ramped FSK   ", "Chirp        ", "BPSK         ", "Not Allowed  "};
+static char *MODULATION[6] = {"Single Tone  ", "FSK          ", "Ramped FSK   ", "Chirp        ", "BPSK         ", "Not Allowed  "};
 
 DDS::DDS(SPI *spi_dev, DigitalOut *mreset, DigitalOut *outramp, DigitalOut *spmode, DigitalOut *cs, DigitalOut *ioreset, DigitalInOut *updclk){
     
@@ -111,11 +105,36 @@
     return read_spi_data;
     }
 
-int DDS::__writeDataAndVerify(char addr, char ndata, const char* wr_spi_data, SerialDriver *screen){
+int DDS::__writeDataAndVerify(char addr, char ndata, char* wr_spi_data, SerialDriver *screen){
     
     int    success;
     char*  rd_spi_data;
     
+    //Avoid some values in Control Register
+    
+    if (addr==0x07){
+        wr_spi_data[2] = wr_spi_data[2] & 0xFE;     //cr_ioupdclk always as an input = 0
+        wr_spi_data[3] = wr_spi_data[3] & 0xFD;     //LSB first = 0, MSB first enabled
+        wr_spi_data[3] = wr_spi_data[3] | 0x01;     //cr_sdo enable = 1
+        
+        cr_qdac_pwdn = (wr_spi_data[0] & 0x04) >> 2;
+        
+        cr_multiplier = (wr_spi_data[1] & 0x1F) >> 0;
+        cr_pll_bypass = (wr_spi_data[1] & 0x20) >> 5;
+        cr_pll_range = (wr_spi_data[1] & 0x40) >> 6;
+        
+        cr_ioupdclk = (wr_spi_data[2] & 0x01) >> 0;
+        cr_mode = (wr_spi_data[2] & 0x07) >> 1;
+        
+        cr_sdo = (wr_spi_data[3] & 0x01) >> 0;
+        cr_msb_lsb = (wr_spi_data[3] & 0x02) >> 1;
+        cr_osk_int = (wr_spi_data[3] & 0x10) >> 4;
+        cr_osk_en = (wr_spi_data[3] & 0x20) >> 5;
+        cr_inv_sinc = (wr_spi_data[3] & 0x40) >> 6;
+        
+    }
+    
+    
     this->__writeData(addr, ndata, wr_spi_data);
     rd_spi_data = this->__readData(addr, ndata);
     
@@ -148,20 +167,18 @@
 }
 
 char* DDS::__getControlRegister(){
-    
-    bool pll_range = 0;
-    bool pll_bypass = 1;
-    
+    /*
     if (cr_multiplier >= 4){
-        pll_bypass = 0;
+        cr_pll_bypass = 0;
     }
 
-    if (clock >= 200){
-        pll_range = 1;
+    if (this->clock >= 200.0){
+        cr_pll_range = 1;
     }
-       
+    */
+    
     controlRegister[0] = 0x10 + cr_qdac_pwdn*4;
-    controlRegister[1] = pll_range*64 + pll_bypass*32 + (cr_multiplier & 0x1F);
+    controlRegister[1] = cr_pll_range*64 + cr_pll_bypass*32 + (cr_multiplier & 0x1F);
     controlRegister[2] = (cr_mode & 0x07)*2 + cr_ioupdclk;
     controlRegister[3] = cr_inv_sinc*64 + cr_osk_en*32 + cr_osk_int*16 + cr_msb_lsb*2 + cr_sdo;
     
@@ -221,6 +238,7 @@
     wait_ms(1);
     
     this->rf_enabled = false;
+    this->programmed = false;
     
     return 0;
     }
@@ -274,17 +292,23 @@
     //printf("\r\nSetting default parameters in CR ...\r\n");
     
     //Serial mode enabled
-    this->clock = 200.0;        // Work clock in MHz
+    this->clock = 200.0;            // Work clock in MHz
     this->cr_multiplier = 4;        // Multiplier 4- 20
     this->cr_mode = 0;              // Single, FSK, Ramped FSK, Chirp, BPSK
     this->cr_qdac_pwdn = 0;         // QDAC power down enabled: 0 -> disable
     this->cr_ioupdclk = 0;          // IO Update clock direction: 0 -> input,  1 -> output
     this->cr_inv_sinc  = 0;         // Sinc inverser filter enable: 0 -> enable
-    this->cr_osk_en = 1;            // Enable Amplitude multiplier: 0 -> disabled
+    this->cr_osk_en = 0;            // Enable Amplitude multiplier: 0 -> disabled
     this->cr_osk_int = 0;           // register/counter output shaped control: 0 -> register, 1 -> counter
     this->cr_msb_lsb = 0;           // msb/lsb bit first: 0 -> MSB, 1 -> LSB
     this->cr_sdo = 1;               // SDO pin active: 0 -> inactive
 
+    this->cr_pll_range = 1;         // Clock >= 200Mhz
+    this->cr_pll_bypass = 0;
+    
+    this->cr_osk_en_bkp = this->cr_osk_en;
+    this->cr_osk_int_bkp = this->cr_osk_int;
+    
     //printf("\r\nSetting in serial mode ...\r\n");
     *dds_sp_mode = 0;
     *dds_cs = 1;
@@ -332,8 +356,8 @@
     
     //Reaconditioning data to return
     rd_data[0] = mult;
-    rd_data[1] = ((int)clock >> 8) & 0xff; 
-    rd_data[2] = (int)clock & 0xff; 
+    rd_data[1] = ((int)(this->clock) >> 8) & 0xff; 
+    rd_data[2] = (int)(this->clock) & 0xff; 
     
     return rd_data;    
     }
@@ -401,6 +425,50 @@
     
     return 0;
     }
+
+int DDS::isAmplitudeEnabled(){
+    
+    if (this->cr_osk_en)
+        return 1;
+    
+    return 0;
+    }
+    
+char* DDS::rdDeltaFrequency(){
+    char* rd_data;
+    
+    rd_data = this->__readData(0x04, 6);
+    
+    return rd_data;
+    
+    }
+
+char* DDS::rdUpdateClock(){
+    char* rd_data;
+    
+    rd_data = this->__readData(0x05, 4);
+    
+    return rd_data;
+    
+    }
+
+char* DDS::rdRampRateClock(){
+    char* rd_data;
+    
+    rd_data = this->__readData(0x06, 3);
+    
+    return rd_data;
+    
+    }
+
+char* DDS::rdAmplitudeRampRate(){
+    char* rd_data;
+    
+    rd_data = this->__readData(0x0A, 1);
+    
+    return rd_data;
+    
+    }
     
 int DDS::wrMode(char mode){
     
@@ -408,7 +476,7 @@
     
     return this->__writeControlRegister();
     }
-
+    
 int DDS::wrMultiplier(char multiplier, float clock){
     
     this->cr_multiplier = multiplier & 0x1F;
@@ -440,7 +508,10 @@
     if (sts){
         for (int i=0; i<6; i++)
             frequency1[i] = freq[i];
+        
+        this->programmed = true;
     }
+    
     return sts;
     
     }
@@ -478,24 +549,109 @@
     
     }
 
+int DDS::wrDeltaFrequency(char* delta_freq, SerialDriver *screen){
+    int sts;
+    
+    sts =  this->__writeDataAndVerify(0x04, 6, delta_freq, screen);
+    
+    if (sts){
+        for (int i=0; i<6; i++)
+            delta_frequency[i] = delta_freq[i];
+    }
+    
+    return sts;
+    
+    }
+
+int DDS::wrUpdateClock(char* upd_clock, SerialDriver *screen){
+    int sts;
+    
+    sts =  this->__writeDataAndVerify(0x05, 4, upd_clock, screen);
+    
+    if (sts){
+        for (int i=0; i<4; i++)
+            update_clock[i] = upd_clock[i];
+    }
+    
+    return sts;
+    
+    }
+
+int DDS::wrRampRateClock(char* rr_clock, SerialDriver *screen){
+    int sts;
+    
+    sts =  this->__writeDataAndVerify(0x06, 3, rr_clock, screen);
+    
+    if (sts){
+        for (int i=0; i<3; i++)
+            ramp_rate_clock[i] = rr_clock[i];
+    }
+    
+    return sts;
+    
+    }
+
+int DDS::wrAmplitudeRampRate(char* ampl_rate, SerialDriver *screen){
+    int sts;
+    
+    sts =  this->__writeDataAndVerify(0x0A, 1, ampl_rate, screen);
+    
+    if (sts){
+        for (int i=0; i<1; i++)
+            amplitude_ramp_rate[i] = ampl_rate[i];
+    }
+    
+    return sts;
+    
+    }
+
+int DDS::enableAmplitude(){
+    
+    this->cr_osk_en = 1; 
+    
+    return this->__writeControlRegister();
+    }
+
+int DDS::disableAmplitude(){
+    
+    this->cr_osk_en = 0; 
+    
+    return this->__writeControlRegister();
+    }
+    
 int DDS::enableRF(){
     
+    this->cr_osk_en = this->cr_osk_en_bkp; 
+    this->cr_osk_int = this->cr_osk_int_bkp; 
+    
+    this->__writeControlRegister();
+    
+    this->__writeDataAndVerify(0x08, 2, this->amplitudeI);
+    
     this->rf_enabled = true;
     
-    this->__writeDataAndVerify(0x08, 2, this->amplitudeI);
     return this->__writeDataAndVerify(0x09, 2, this->amplitudeQ);
 
     }
 
 int DDS::disableRF(){
     
+    this->cr_osk_en_bkp = this->cr_osk_en;
+    this->cr_osk_int_bkp = this->cr_osk_int;
+    
+    this->cr_osk_en = 1; 
+    this->cr_osk_int = 0; 
+    
+    this->__writeControlRegister();
+    
+    this->__writeDataAndVerify(0x08, 2, "\x00\x00");
+    
     this->rf_enabled = false;
     
-    this->__writeDataAndVerify(0x08, 2, "\x00\x00");
     return this->__writeDataAndVerify(0x09, 2, "\x00\x00");
     
     }
-       
+     
 int DDS::defaultSettings(SerialDriver *screen){
     
     if (!(screen == NULL)){
@@ -510,25 +666,26 @@
     this->wrFrequency2("\x00\x00\x00\x00\x00\x00");
     this->wrPhase1("\x00\x00");                            //0 grados
     this->wrPhase2("\x20\x00");                            //180 grados <> 0x20 0x00 <> 180/360*(2**14)
+    this->disableAmplitude();
     this->disableRF();
         
     if (!(screen == NULL)){
         screen->putc(0x37);
         screen->putc(0x31);
     }
-    
-    return this->wrMode(4);                                //BPSK mode
+    this->programmed = false;
+    return this->wrMode(0);                                //BPSK mode
     
     }
     
 char* DDS::setCommand(unsigned short cmd, char* payload, unsigned long payload_len){
     
-    bool success = false;    
-    char* tx_msg;
-    unsigned long tx_msg_len;
+    bool success = false;
     
-    tx_msg = KO_MSG;
-    tx_msg_len = 2;
+    strcpy(message, MSG_CMD_OK);
+    
+    this->cmd_answer = message;
+    this->cmd_answer_len = strlen(message);
     
     //printf("cmd = %d, payload_len = %d", cmd, payload_len);
 
@@ -538,8 +695,11 @@
     
     //Si el DDS no esta inicializado siempre retornar NI_MSG
     if (not this->isConfig){
-        this->cmd_answer = NI_MSG;
-        this->cmd_answer_len = 2;
+        
+        strcpy(message, MSG_STATUS_FAIL);
+        
+        this->cmd_answer = message;
+        this->cmd_answer_len = strlen(message);
         
         return this->cmd_answer;
     }
@@ -548,6 +708,22 @@
       {
         case DDS_CMD_RESET:
             success = this->init();
+            success = this->defaultSettings();
+            break;
+        
+        case DDS_CMD_STATUS:
+            
+            if (this->programmed == false)
+                strcpy(message, MSG_STATUS_ON);
+            
+            if ((this->programmed == true) && (this->rf_enabled == false)) 
+                strcpy(message, MSG_STATUS_RF_DIS);
+            
+            if ((this->programmed == true) && (this->rf_enabled == true))
+                strcpy(message, MSG_STATUS_RF_ENA);
+            
+            this->cmd_answer = message;
+            this->cmd_answer_len = strlen(message);
             break;
             
         case DDS_CMD_ENABLE_RF:
@@ -558,7 +734,16 @@
                     success = this->enableRF();
             }
             break;
-            
+        
+        case DDS_CMD_ENABLE_AMP:
+            if (payload_len == 1){
+                if (payload[0] == 0)
+                    success = this->disableAmplitude();
+                else
+                    success = this->enableAmplitude();
+            }
+            break;
+        
         case DDS_CMD_MULTIPLIER:
             if (payload_len == 1){
                 success = this->wrMultiplier(payload[0]);
@@ -610,71 +795,137 @@
                 success = this->wrAmplitudeQ(payload);
             }
             break;
-
+        
+        case DDS_CMD_AMP_RAMP_RATE:
+            if (payload_len == 1){
+                success = this->wrAmplitudeRampRate(payload);
+            }
+            break;
+        
+        case DDS_CMD_DELTA_FREQ:
+            if (payload_len == 1){
+                success = this->wrDeltaFrequency(payload);
+            }
+            break;
+        
+        case DDS_CMD_UPD_CLOCK:
+            if (payload_len == 1){
+                success = this->wrUpdateClock(payload);
+            }
+            break;
+        
+        case DDS_CMD_RAMP_RATE_CLOCK:
+            if (payload_len == 1){
+                success = this->wrRampRateClock(payload);
+            }
+            break;
+            
         case DDS_CMD_READ | DDS_CMD_ENABLE_RF:
             if (this->isRFEnabled() == 1)
-                tx_msg = ONE_MSG;
+                strcpy(message, MSG_ENABLED);
             else
-                tx_msg = ZERO_MSG;
+                strcpy(message, MSG_DISABLED);
                 
-            tx_msg_len = 1;
+            this->cmd_answer_len = strlen(message);
             
             break;
             
+        case DDS_CMD_READ | DDS_CMD_ENABLE_AMP:
+            if (this->cr_osk_en == 1)
+                strcpy(message, MSG_ENABLED);
+            else
+                strcpy(message, MSG_DISABLED);
+                
+            this->cmd_answer_len = strlen(message);
+            
+            break;
+                  
         case DDS_CMD_READ | DDS_CMD_MULTIPLIER:
-            tx_msg = this->rdMultiplier();
-            tx_msg_len = 1;
+            this->cmd_answer = this->rdMultiplier();
+            this->cmd_answer_len = 1;
             break;
             
         case DDS_CMD_READ | DDS_CMD_MODE:
-            tx_msg = this->rdMode();
-            tx_msg_len = 1;
+            this->cmd_answer = this->rdMode();
+            this->cmd_answer_len = 1;
             break;
             
         case DDS_CMD_READ | DDS_CMD_FREQUENCYA:
-            tx_msg = this->rdFrequency1();
-            tx_msg_len = 6;
+            this->cmd_answer = this->rdFrequency1();
+            this->cmd_answer_len = 6;
             break;
             
         case DDS_CMD_READ | DDS_CMD_FREQUENCYB:
-            tx_msg = this->rdFrequency2();
-            tx_msg_len = 6;
+            this->cmd_answer = this->rdFrequency2();
+            this->cmd_answer_len = 6;
             break;
             
         case DDS_CMD_READ | DDS_CMD_PHASEA:
-            tx_msg = this->rdPhase1();
-            tx_msg_len = 2;
+            this->cmd_answer = this->rdPhase1();
+            this->cmd_answer_len = 2;
             break;
             
         case DDS_CMD_READ | DDS_CMD_PHASEB:
-            tx_msg = this->rdPhase2();
-            tx_msg_len = 2;
+            this->cmd_answer = this->rdPhase2();
+            this->cmd_answer_len = 2;
             break;
 
         case DDS_CMD_READ | DDS_CMD_AMPLITUDE1:
-            tx_msg = this->rdAmplitudeI();
-            tx_msg_len = 2;
+            this->cmd_answer = this->rdAmplitudeI();
+            this->cmd_answer_len = 2;
             break;
 
         case DDS_CMD_READ | DDS_CMD_AMPLITUDE2:
-            tx_msg = this->rdAmplitudeQ();
-            tx_msg_len = 2;
+            this->cmd_answer = this->rdAmplitudeQ();
+            this->cmd_answer_len = 2;
+            break;
+        
+        case DDS_CMD_READ | DDS_CMD_AMP_RAMP_RATE:
+            this->cmd_answer = this->rdAmplitudeRampRate();
+            this->cmd_answer_len = 1;
+            break;
+        
+        case DDS_CMD_READ | DDS_CMD_DELTA_FREQ:
+            this->cmd_answer = this->rdDeltaFrequency();
+            this->cmd_answer_len = 6;
+            break;
+        
+        case DDS_CMD_READ | DDS_CMD_UPD_CLOCK:
+            this->cmd_answer = this->rdUpdateClock();
+            this->cmd_answer_len = 4;
+            break;
+        
+        case DDS_CMD_READ | DDS_CMD_RAMP_RATE_CLOCK:
+            this->cmd_answer = this->rdRampRateClock();
+            this->cmd_answer_len = 3;
+            break;
+        
+        case DDS_CMD_WRITE:
+            if (payload_len == 0x28){
+                success = this->writeAllDevice(payload);
+            }
+            break;
+        
+        case DDS_CMD_READ:
+            this->cmd_answer = this->readAllDevice();
+            this->cmd_answer_len = 0x28;
             break;
             
         default:
             success = false;
+            strcpy(message, MSG_CMD_KO);
+            this->cmd_answer = message;
+            this->cmd_answer_len = strlen(message);
         
       }
     
     if (success){
-        tx_msg = OK_MSG;
-        tx_msg_len = 2;
+        strcpy(message, MSG_CMD_OK);
+        this->cmd_answer = message;
+        this->cmd_answer_len = strlen(message);
         }
     
-    this->cmd_answer = tx_msg;
-    this->cmd_answer_len = tx_msg_len;
-    
-    return tx_msg;
+    return this->cmd_answer;
 }
 
 char* DDS::getCmdAnswer(){
@@ -689,55 +940,6 @@
     
     }
 
-int DDS::setAllDevice(char* payload, SerialDriver *screen){
-    
-    int sts;
-    char* phase1, *phase2;
-    char* freq1, *freq2;
-    char* delta_freq, *upd_rate_clk, *ramp_rate_clk;
-    char* control_reg;
-    char* amplitudeI, *amplitudeQ, *ampl_ramp_rate;
-    char* qdac;
-    
-    phase1 = &payload[0x00];
-    phase2 = &payload[0x02];
-    freq1 = &payload[0x04];
-    freq2 = &payload[0x0A];
-    delta_freq = &payload[0x10];
-    upd_rate_clk = &payload[0x16];
-    ramp_rate_clk = &payload[0x1A];
-    control_reg = &payload[0x1D];
-    amplitudeI = &payload[0x21];
-    amplitudeQ = &payload[0x23];
-    ampl_ramp_rate = &payload[0x25];
-    qdac = &payload[0x26];
-    
-    control_reg[2] = control_reg[2] & 0xFE;     //cr_ioupdclk always as an input = 0
-    control_reg[3] = control_reg[3] & 0xFD;     //LSB first = 0, MSB first enabled
-    control_reg[3] = control_reg[3] | 0x01;     //cr_sdo enable = 1
-    
-    this->__writeDataAndVerify(0x04, 6, delta_freq);
-    this->__writeDataAndVerify(0x05, 4, upd_rate_clk);
-    this->__writeDataAndVerify(0x06, 3, ramp_rate_clk);
-    this->__writeDataAndVerify(0x07, 4, control_reg);
-    
-    this->__writeDataAndVerify(0x0A, 1, ampl_ramp_rate);
-    this->__writeDataAndVerify(0x0B, 2, qdac, screen);  
-
-    this->wrPhase1(phase1);
-    this->wrPhase2(phase2);
-    this->wrFrequency1(freq1);
-    this->wrFrequency2(freq2);
-    this->wrAmplitudeI(amplitudeI);
-    this->wrAmplitudeQ(amplitudeQ);
-    
-    //Enabling RF
-    sts = this->enableRF();
-    
-    return sts;
-    
-    }
-
 bool DDS::wasInitialized(){
     
     return this->isConfig;
@@ -771,4 +973,148 @@
         return MODULATION[5];
     
     return MODULATION[this->cr_mode];   
-}
\ No newline at end of file
+}
+
+
+int DDS::writeAllDevice(char* payload, SerialDriver *screen){
+    
+    int sts;
+    char* phase1, *phase2;
+    char* freq1, *freq2;
+    char* delta_freq, *upd_rate_clk, *ramp_rate_clk;
+    char* control_reg;
+    char* amplitudeI, *amplitudeQ, *ampl_ramp_rate;
+    char* qdac;
+    
+    //parm = payload[ParallelAddress]
+    phase1 = &payload[0x00];
+    phase2 = &payload[0x02];
+    freq1 = &payload[0x04];
+    freq2 = &payload[0x0A];
+    delta_freq = &payload[0x10];
+    upd_rate_clk = &payload[0x16];
+    ramp_rate_clk = &payload[0x1A];
+    control_reg = &payload[0x1D];
+    amplitudeI = &payload[0x21];
+    amplitudeQ = &payload[0x23];
+    ampl_ramp_rate = &payload[0x25];
+    qdac = &payload[0x26];
+    
+    control_reg[2] = control_reg[2] & 0xFE;     //cr_ioupdclk always as an input = 0 when serial operation is used
+    control_reg[3] = control_reg[3] & 0xFD;     //LSB first = 0, MSB first enabled
+    control_reg[3] = control_reg[3] | 0x01;     //cr_sdo enable = 1
+    
+    cr_osk_int_bkp = (control_reg[3] & 0x10) >> 4;
+    cr_osk_en_bkp = (control_reg[3] & 0x20) >> 5;
+        
+    //this->__writeDataAndVerify(SerialAddress, NumberOfBytes, Bytes);
+    //this->__writeDataAndVerify(0x04, 6, delta_freq);
+    //this->__writeDataAndVerify(0x05, 4, upd_rate_clk);
+    //this->__writeDataAndVerify(0x06, 3, ramp_rate_clk);
+    this->__writeDataAndVerify(0x07, 4, control_reg);
+    
+    //this->__writeDataAndVerify(0x0A, 1, ampl_ramp_rate);
+    this->__writeDataAndVerify(0x0B, 2, qdac, screen);  
+
+    this->wrPhase1(phase1);
+    this->wrPhase2(phase2);
+    this->wrFrequency1(freq1);
+    this->wrFrequency2(freq2);
+    this->wrDeltaFrequency(delta_freq);
+    this->wrUpdateClock(upd_rate_clk);
+    this->wrRampRateClock(ramp_rate_clk);
+    
+    this->wrAmplitudeI(amplitudeI);
+    this->wrAmplitudeQ(amplitudeQ);
+    
+    this->wrAmplitudeRampRate(ampl_ramp_rate);
+    
+    //Enabling RF
+    sts = this->enableRF();
+    
+    return sts;
+    
+    }
+    
+
+char* DDS::readAllDevice(){
+    
+    char* rd_data;
+    int i=0, k=0;
+    
+    rd_data = this->rdPhase1();
+    
+    for (i=0; i<2; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    rd_data = this->rdPhase2();
+    
+    for (i=0; i<2; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    rd_data = this->rdFrequency1();
+    
+    for (i=0; i<6; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    rd_data = this->rdFrequency2();
+    
+    for (i=0; i<6; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    rd_data = this->rdDeltaFrequency();
+    
+    for (i=0; i<6; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    rd_data = this->rdUpdateClock();
+    
+    for (i=0; i<4; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    rd_data = this->rdRampRateClock();
+    
+    for (i=0; i<3; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    rd_data = this->__readData(0x07, 4);
+    
+    for (i=0; i<4; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    rd_data = this->rdAmplitudeI();
+    
+    for (i=0; i<2; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    rd_data = this->rdAmplitudeQ();
+    
+    
+    for (i=0; i<2; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    rd_data = this->rdAmplitudeRampRate();
+    
+    for (i=0; i<1; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    rd_data = this->__readData(0x0B, 2);
+    
+    for (i=0; i<2; i++)
+        message[k+i] = rd_data[i];
+    k += i;
+    
+    return message;
+    
+    }
\ No newline at end of file
diff -r 156a9e15919e -r d81fca2297fb AD9854.h
--- a/AD9854.h	Tue Feb 24 20:08:13 2015 +0000
+++ b/AD9854.h	Wed Sep 04 22:26:24 2019 +0000
@@ -8,6 +8,8 @@
 #define SPI_MODE 0
 #define SPI_FREQ 1000000
 
+#define DDS_CMD_STATUS      0X04
+
 #define DDS_CMD_RESET       0X10
 #define DDS_CMD_ENABLE_RF   0x11
 #define DDS_CMD_MULTIPLIER  0X12
@@ -18,8 +20,27 @@
 #define DDS_CMD_PHASEB      0x17
 #define DDS_CMD_AMPLITUDE1  0X18
 #define DDS_CMD_AMPLITUDE2  0x19
+#define DDS_CMD_ENABLE_AMP      0x1A
+#define DDS_CMD_AMP_RAMP_RATE   0x1B
+#define DDS_CMD_DELTA_FREQ      0x1C
+#define DDS_CMD_UPD_CLOCK       0x1D
+#define DDS_CMD_RAMP_RATE_CLOCK 0x1E
+
+#define DDS_CMD_WRITE       0x50
 #define DDS_CMD_READ        0x8000
 
+#define MSG_CMD_KO          "0:Command not recognized"
+#define MSG_CMD_OK          "1:Configuration received and saved"
+
+#define MSG_STATUS_FAIL     "0:DDS Clock not connected"
+#define MSG_STATUS_ON       "1:DDS was not programmed"
+#define MSG_STATUS_RF_DIS   "2:RF disabled"
+#define MSG_STATUS_RF_ENA   "3:RF enabled"
+
+#define MSG_DISABLED     "0:ENABLED"
+#define MSG_ENABLED      "1:DISABLED"
+
+
 class DDS{
     private:
         float           clock;              // Work frequency in MHz
@@ -32,14 +53,25 @@
         bool            cr_osk_int;             // ext/int output shaped control: 0 -> external
         bool            cr_msb_lsb;             // msb/lsb bit first: 0 -> MSB
         bool            cr_sdo;                 // SDO pin active: 0 -> inactive
-
+        bool            cr_pll_range;
+        bool            cr_pll_bypass;
+    
+        bool            cr_osk_en_bkp;              // Enable AM: 0 -> disabled
+        bool            cr_osk_int_bkp;
+    
         char            frequency1[6];
         char            frequency2[6];
         char            phase1[2];
         char            phase2[2];       
         char            amplitudeI[2];
         char            amplitudeQ[2];
+        char            delta_frequency[6];
+        char            update_clock[4];
+        char            ramp_rate_clock[3];
+        char            amplitude_ramp_rate[1];
+        
         bool            rf_enabled;
+        bool            programmed;
        
         double          factor_freq1;
         double          factor_freq2;
@@ -58,7 +90,7 @@
         
         int __writeData(char addr, char ndata, const char* data);
         char* __readData(char addr, char ndata);
-        int __writeDataAndVerify(char addr, char ndata, const char* wr_spi_data, SerialDriver *screen=NULL);
+        int __writeDataAndVerify(char addr, char ndata, char* wr_spi_data, SerialDriver *screen=NULL);
         char* __getControlRegister();
         int __writeControlRegister();
         
@@ -79,7 +111,14 @@
         char* rdFrequency2();
         char* rdAmplitudeI();
         char* rdAmplitudeQ();
+        char* rdDeltaFrequency();
+        char* rdUpdateClock();
+        char* rdRampRateClock();
+        char* rdAmplitudeRampRate();
+        
         int isRFEnabled();
+        int isAmplitudeEnabled();
+        
         int wrMode(char mode);
         int wrMultiplier(char multiplier, float clock=200.0);
         int wrPhase1(char* phase, SerialDriver *screen=NULL);
@@ -88,13 +127,21 @@
         int wrFrequency2(char* freq, SerialDriver *screen=NULL);
         int wrAmplitudeI(char* amplitude, SerialDriver *screen=NULL);
         int wrAmplitudeQ(char* amplitude, SerialDriver *screen=NULL);
+        int wrDeltaFrequency(char* delta_freq, SerialDriver *screen=NULL);
+        int wrUpdateClock(char* upd_clock, SerialDriver *screen=NULL);
+        int wrRampRateClock(char* rr_clock, SerialDriver *screen=NULL);
+        int wrAmplitudeRampRate(char* ampl_ramp_rate, SerialDriver *screen=NULL);
+        
         int enableRF();
         int disableRF();
+        int enableAmplitude();
+        int disableAmplitude();
+        
         int defaultSettings(SerialDriver *screen=NULL);
         char* setCommand(unsigned short cmd, char* payload, unsigned long payload_len);
         char* getCmdAnswer();
         unsigned long getCmdAnswerLen();
-        int setAllDevice(char* payload, SerialDriver *screen=NULL);
+        
         bool wasInitialized();
         char getMultiplier();
         double getFreqFactor1();
@@ -102,6 +149,9 @@
         char getMode();
         char* getModeStr();
         
+        int writeAllDevice(char* payload, SerialDriver *screen=NULL);
+        char* readAllDevice();
+        
 };
 
 #endif
\ No newline at end of file