diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 663f8d2a2..14eca3a6d 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 410e67da8..df2fb0a1a 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -470,6 +470,7 @@ void setupDetector() { initReadoutConfiguration(); // Initialization of acquistion parameters + disableCurrentSource(); setSettings(DEFAULT_SETTINGS); setGainMode(DEFAULT_GAINMODE); @@ -499,7 +500,6 @@ void setupDetector() { setFilterResistor(DEFAULT_FILTER_RESISTOR); setFilterCell(DEFAULT_FILTER_CELL); } - disableCurrentSource(); setReadNRows(MAX_ROWS_PER_READOUT); } @@ -1106,10 +1106,8 @@ enum detectorSettings setSettings(enum detectorSettings sett) { setDAC(specialDacs[i], dacVals[i], 0); } - // if chip 1.1, and power chip on, configure chip - if (getChipVersion() == 11 && powerChip(-1)) { - configureChip(); - } + // if chipv1.1 and powered on + configureChip(); return getSettings(); } @@ -1749,16 +1747,25 @@ int isChipConfigured() { } void configureChip() { - // only for chipv1.1 - if (getChipVersion() == 11) { - LOG(logINFOBLUE, ("Configuring chip\n")); + // only for chipv1.1 and chip is powered on + if (getChipVersion() == 11 && powerChip(-1)) { + LOG(logINFOBLUE, ("\tConfiguring chip\n")); + + // waiting 500 ms before configuring selection + usleep(500 * 1000); + + // write same values to configure selection + // if (chip was powered off earlier) + LOG(logINFO, ("\tSetting default values for selection\n")) + bus_w(CRRNT_SRC_COL_LSB_REG, bus_r(CRRNT_SRC_COL_LSB_REG)); + bus_w(CRRNT_SRC_COL_MSB_REG, bus_r(CRRNT_SRC_COL_MSB_REG)); + // waiting 500 ms before configuring chip usleep(500 * 1000); + // write same register values back to configure chip bus_w(CONFIG_V11_REG, bus_r(CONFIG_V11_REG)); - // default values for current source - bus_w(CRRNT_SRC_COL_LSB_REG, BIT32_MASK); - bus_w(CRRNT_SRC_COL_MSB_REG, BIT32_MASK); + chipConfigured = 1; } } @@ -2205,11 +2212,18 @@ void setFilterCell(int iCell) { void disableCurrentSource() { LOG(logINFO, ("Disabling Current Source\n")); - bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_ENBL_MSK); - // default values for current source - bus_w(CRRNT_SRC_COL_LSB_REG, BIT32_MASK); - bus_w(CRRNT_SRC_COL_MSB_REG, BIT32_MASK); + // set default values for current source first + if (getChipVersion() == 11) { + LOG(logINFO, ("\tSetting default values for selection\n")) + bus_w(CRRNT_SRC_COL_LSB_REG, BIT32_MASK); + bus_w(CRRNT_SRC_COL_MSB_REG, BIT32_MASK); + } + + bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_ENBL_MSK); + LOG(logINFO, ("\tCurrent Source disabled\n")); + + configureChip(); } void enableCurrentSource(int fix, uint64_t select, int normal) { @@ -2222,15 +2236,17 @@ void enableCurrentSource(int fix, uint64_t select, int normal) { fix, (long long int)select, normal)); } disableCurrentSource(); - LOG(logINFO, ("\tSetting current source parameters\n")); // fix if (fix) { + LOG(logINFO, ("\tEnabling fix\n")); bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_CRRNT_SRC_CLMN_FIX_MSK); } else { + LOG(logINFO, ("\tDisabling fix\n")); bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_CLMN_FIX_MSK); } if (getChipVersion() == 10) { // select + LOG(logINFO, ("\tSetting selection\n")) bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_CLMN_SLCT_MSK); bus_w(DAQ_REG, bus_r(DAQ_REG) | ((select << DAQ_CRRNT_SRC_CLMN_SLCT_OFST) & @@ -2238,12 +2254,15 @@ void enableCurrentSource(int fix, uint64_t select, int normal) { } else { // select + LOG(logINFO, ("\tSetting selection\n")) set64BitReg(select, CRRNT_SRC_COL_LSB_REG, CRRNT_SRC_COL_MSB_REG); // normal if (normal) { + LOG(logINFO, ("\tEnabling normal\n")) bus_w(CONFIG_V11_REG, bus_r(CONFIG_V11_REG) & ~CONFIG_V11_CRRNT_SRC_LOW_MSK); } else { + LOG(logINFO, ("\tEnabling low\n")) bus_w(CONFIG_V11_REG, bus_r(CONFIG_V11_REG) | CONFIG_V11_CRRNT_SRC_LOW_MSK); } @@ -2258,8 +2277,10 @@ void enableCurrentSource(int fix, uint64_t select, int normal) { // acquisition // enabling current source - LOG(logINFO, ("Enabling Current Source\n")); + LOG(logINFO, ("\tEnabling Current Source\n")); bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_CRRNT_SRC_ENBL_MSK); + + configureChip(); } int getCurrentSource() { diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 398a0df88..0bd059325 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -10,4 +10,4 @@ #define APIMYTHEN3 0x211005 #define APIMOENCH 0x210927 #define APIEIGER 0x211005 -#define APIJUNGFRAU 0x211006 +#define APIJUNGFRAU 0x211007