diff --git a/RELEASE.txt b/RELEASE.txt index 96352882b..abf35629d 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -75,6 +75,8 @@ This document describes the differences between v7.0.0 and v6.x.x - rxr src files and classes (detectordata, ZmqSocket, helpDacs) added to sls namespace, and macros (namely from logger (logINFO etc)), slsDetectorGui (make_unique in implemtnation requires sls nemspace (points to std otherwise) but not deectorImpl.cpp) - blackfin programing made seamless (nCE fixed which helps) -save settings file for m3 and eiger +- g2 and m3 clkdiv 2 (system clock) change should affect time settings (g2: exptime, period, delayaftertrigger, burstperiod, m3: exptime, gatedelay, gateperiod, period, delayaftertrigger) +- g2 system frequency is the same irrespective of timing source 2. Resolved Issues ================== diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index aadfc5f1a..3b19c601a 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index e43d711ea..e65719c07 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -2297,6 +2297,24 @@ int setClockDivider(enum CLKINDEX ind, int val) { setPhase(i, oldPhases[i], 1); } } + + // update system frequency and time settings that depend on it + if (ind == SYSTEM_C0) { + LOG(logINFO, ("\tUpdating time settings (sys freq change)\n")); + int64_t exptime = getExpTime(); + int64_t period = getPeriod(); + int64_t delayAfterTrigger = getDelayAfterTrigger(); + int64_t burstPeriod = getBurstPeriod(); + + systemFrequency = ((double)getVCOFrequency(SYSTEM_C0) / + (double)clkDivider[SYSTEM_C0]); + + setExpTime(exptime); + setPeriod(period); + setDelayAfterTrigger(delayAfterTrigger); + setBurstPeriod(burstPeriod); + LOG(logINFO, ("\tDone updating time settings\n")); + } return OK; } @@ -2798,13 +2816,10 @@ void setTimingSource(enum timingSourceType value) { case TIMING_INTERNAL: LOG(logINFO, ("Setting timing source to internal\n")); bus_w(addr, (bus_r(addr) & ~CONTROL_TIMING_SOURCE_EXT_MSK)); - systemFrequency = INT_SYSTEM_C0_FREQUENCY; break; case TIMING_EXTERNAL: LOG(logINFO, ("Setting timing source to exernal\n")); bus_w(addr, (bus_r(addr) | CONTROL_TIMING_SOURCE_EXT_MSK)); - systemFrequency = ((double)getVCOFrequency(SYSTEM_C0) / - (double)clkDivider[SYSTEM_C0]); break; default: LOG(logERROR, ("Unknown timing source %d\n", value)); diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index ffc54469f..59ce094cc 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index d943322c5..ce96f5f78 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -1331,7 +1331,7 @@ int setTrimbits(int *trimbits) { uint32_t prevRunClk = clkDivider[SYSTEM_C0]; // set to trimming clock - if (setClockDivider(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV) == FAIL) { + if (setClockDividerWithTimeUpdateOption(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV, 0) == FAIL) { LOG(logERROR, ("Could not start trimming. Could not set to trimming clock\n")); return FAIL; @@ -1364,7 +1364,7 @@ int setTrimbits(int *trimbits) { } // set back to previous clock - if (setClockDivider(SYSTEM_C0, prevRunClk) == FAIL) { + if (setClockDividerWithTimeUpdateOption(SYSTEM_C0, prevRunClk, 0) == FAIL) { LOG(logERROR, ("Could not set to previous run clock after trimming\n")); return FAIL; } @@ -2215,6 +2215,10 @@ int getVCOFrequency(enum CLKINDEX ind) { int getMaxClockDivider() { return ALTERA_PLL_C10_GetMaxClockDivider(); } int setClockDivider(enum CLKINDEX ind, int val) { + return setClockDividerWithTimeUpdateOption(ind, val, 1); +} + +int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val, int timeUpdate) { if (ind < 0 || ind >= NUM_CLOCKS) { LOG(logERROR, ("Unknown clock index %d to set clock divider\n", ind)); return FAIL; @@ -2239,6 +2243,32 @@ int setClockDivider(enum CLKINDEX ind, int val) { int pllIndex = (int)(ind >= SYSTEM_C0 ? SYSTEM_PLL : READOUT_PLL); int clkIndex = (int)(ind >= SYSTEM_C0 ? ind - SYSTEM_C0 : ind); ALTERA_PLL_C10_SetOuputClockDivider(pllIndex, clkIndex, val); + + // Update time settings that depend on system frequency + // timeUpdate = 0 for setChipRegister/setTrimbits etc + // as clk reverted back again + if (timeUpdate && ind == SYSTEM_C0) { + LOG(logINFO, ("\tUpdating time settings (sys freq change)\n")); + int64_t exptime[3] = {0, 0, 0}; + int64_t gateDelay[3] = {0, 0, 0}; + for (int i = 0; i != 3; ++i) { + exptime[i] = getExpTime(i); + gateDelay[i] = getGateDelay(i); + } + int64_t period = getPeriod(); + int64_t delayAfterTrigger = getDelayAfterTrigger(); + + clkDivider[ind] = val; + + for (int i = 0; i != 3; ++i) { + setExpTime(i, exptime[i]); + setGateDelay(i, gateDelay[i]); + } + setPeriod(period); + setDelayAfterTrigger(delayAfterTrigger); + LOG(logINFO, ("\tDone updating time settings\n")); + } + clkDivider[ind] = val; LOG(logINFO, ("\t%s clock (%d) divider set to %d\n", clock_names[ind], ind, clkDivider[ind])); @@ -2629,7 +2659,7 @@ int setChipStatusRegister(int csr) { uint32_t prevRunClk = clkDivider[SYSTEM_C0]; // set to trimming clock - if (setClockDivider(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV) == FAIL) { + if (setClockDividerWithTimeUpdateOption(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV, 0) == FAIL) { LOG(logERROR, ("Could not set to trimming clock in order to change CSR\n")); return FAIL; @@ -2651,7 +2681,7 @@ int setChipStatusRegister(int csr) { } // set back to previous clock - if (setClockDivider(SYSTEM_C0, prevRunClk) == FAIL) { + if (setClockDividerWithTimeUpdateOption(SYSTEM_C0, prevRunClk, 0) == FAIL) { LOG(logERROR, ("Could not set to previous run clock after changing CSR\n")); return FAIL; diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 05d84e9b4..3ae08b95d 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -565,6 +565,7 @@ int getFrequency(enum CLKINDEX ind); int getVCOFrequency(enum CLKINDEX ind); int getMaxClockDivider(); int setClockDivider(enum CLKINDEX ind, int val); +int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val, int timeUpdate); int getClockDivider(enum CLKINDEX ind); #elif GOTTHARD2D diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 6674b9f8d..97ff2a907 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -7,8 +7,8 @@ #define APIGUI 0x220328 #define APICTB 0x220524 #define APIGOTTHARD 0x220524 -#define APIGOTTHARD2 0x220524 #define APIJUNGFRAU 0x220524 -#define APIMYTHEN3 0x220524 #define APIMOENCH 0x220519 #define APIEIGER 0x220524 +#define APIMYTHEN3 0x220602 +#define APIGOTTHARD2 0x220602