# HG changeset patch # User Daniele Nicolodi # Date 1433533885 -7200 # Node ID 8cbfce046d410625eca147d916fdb44b13d65e36 # Parent 708de02ef94898416a2211ba862aa0f5b66ff6b8 Try to read back the frequency values from AD9912 at startup Reset the AD9912 frequencies to the default value only as a fallback. diff -r 708de02ef948 -r 8cbfce046d41 FXAnalyse.c --- a/FXAnalyse.c Fri Jun 05 21:00:54 2015 +0200 +++ b/FXAnalyse.c Fri Jun 05 21:51:25 2015 +0200 @@ -719,12 +719,11 @@ int main (int argc, char *argv[]) { - int rv; - int nchan; - double frequency; + int i, rv, nchan; + double frequency, clock; char expr[1024]; char host[256]; - double clock; + int PANEL_DDS[4] = { PANEL_DDS1, PANEL_DDS2, PANEL_DDS3, PANEL_DDS4 }; if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) return -1; @@ -786,14 +785,16 @@ if (rv) logmessage(ERROR, "ad9912 init erorr=%d", -rv); - GetCtrlVal(MainPanel, PANEL_DDS1, &frequency); - ad9912_set_frequency_w(&ad9912, 0, frequency); - GetCtrlVal(MainPanel, PANEL_DDS2, &frequency); - ad9912_set_frequency_w(&ad9912, 1, frequency); - GetCtrlVal(MainPanel, PANEL_DDS3, &frequency); - ad9912_set_frequency_w(&ad9912, 2, frequency); - GetCtrlVal(MainPanel, PANEL_DDS4, &frequency); - ad9912_set_frequency_w(&ad9912, 3, frequency); + // try to read back current frequency from DDS + for (i = 0; i < 4; i++) { + rv = ad9912_get_frequency(&ad9912, i, &frequency); + if ((rv) || (frequency == 0.0)) { + logmessage(WARNING, "reset DDS%d frequency to default value", i + 1); + GetCtrlVal(MainPanel, PANEL_DDS[i], &frequency); + ad9912_set_frequency_w(&ad9912, i, frequency); + } + SetCtrlVal(MainPanel, PANEL_DDS[i], frequency); + } // setup ZMQ pub socket char *socket;