diff --git a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h index 854de5380..328e8f20a 100644 --- a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h @@ -103,6 +103,19 @@ /* Config RW regiseter */ #define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL) +#define CONFIG_COUNTER_ENA_OFST (0) +#define CONFIG_COUNTER_ENA_MSK (0x00000003 << CONFIG_COUNTER_ENA_OFST) +#define CONFIG_COUNTER_ENA_DEFAULT_VAL ((0x0 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK) +#define CONFIG_COUNTER_ENA_1_VAL ((0x1 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK) +#define CONFIG_COUNTER_ENA_2_VAL ((0x2 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK) +#define CONFIG_COUNTER_ENA_ALL_VAL ((0x3 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK) +#define CONFIG_DYNAMIC_RANGE_OFST (4) +#define CONFIG_DYNAMIC_RANGE_MSK (0x00000003 << CONFIG_DYNAMIC_RANGE_OFST) +#define CONFIG_DYNAMIC_RANGE_1_VAL ((0x0 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK) +#define CONFIG_DYNAMIC_RANGE_4_VAL ((0x1 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK) +#define CONFIG_DYNAMIC_RANGE_16_VAL ((0x2 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK) +#define CONFIG_DYNAMIC_RANGE_24_VAL ((0x3 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK) + /* Control RW register */ // assumed for MY3 #define CONTROL_REG (0x21 * REG_OFFSET + BASE_CONTROL) diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 9f8919b8b..c9ab60226 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 0740690cd..2a3efb317 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -368,6 +368,13 @@ void setupDetector() { // defaults setHighVoltage(DEFAULT_HIGH_VOLTAGE); setDefaultDacs(); + + // dynamic range + setDynamicRange(DEFAULT_DYNAMIC_RANGE); + // enable all counters + bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_COUNTER_ENA_MSK); + bus_w(CONFIG_REG, bus_r(CONFIG_REG) | CONFIG_COUNTER_ENA_ALL_VAL); + // Initialization of acquistion parameters setNumFrames(DEFAULT_NUM_FRAMES); @@ -419,7 +426,45 @@ void resetPeripheral() { /* set parameters - dr, roi */ int setDynamicRange(int dr){ - return 32; //TODO + if (dr > 0) { + uint32_t regval = 0; + switch(dr) { + case 1: + regval = CONFIG_DYNAMIC_RANGE_1_VAL; + break; + case 4: + regval = CONFIG_DYNAMIC_RANGE_4_VAL; + break; + case 16: + regval = CONFIG_DYNAMIC_RANGE_16_VAL; + break; + case 24: + case 32: + regval = CONFIG_DYNAMIC_RANGE_24_VAL; + break; + default: + FILE_LOG(logERROR, ("Invalid dynamic range %d\n", dr)); + return -1; + } + // set it + bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_DYNAMIC_RANGE_MSK); + bus_w(CONFIG_REG, bus_r(CONFIG_REG) | regval); + } + + uint32_t regval = bus_r(CONFIG_REG & CONFIG_DYNAMIC_RANGE_MSK); + switch(regval) { + case CONFIG_DYNAMIC_RANGE_1_VAL: + return 1; + case CONFIG_DYNAMIC_RANGE_4_VAL: + return 4; + case CONFIG_DYNAMIC_RANGE_16_VAL: + return 16; + case CONFIG_DYNAMIC_RANGE_24_VAL: + return 32; + default: + FILE_LOG(logERROR, ("Invalid dynamic range %d read back\n", regval >> CONFIG_DYNAMIC_RANGE_OFST)); + return -1; + } } diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h index d5d41ce61..f407d9847 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h @@ -17,6 +17,7 @@ #define DAC_MAX_MV (2048) /** Default Parameters */ +#define DEFAULT_DYNAMIC_RANGE (24) #define DEFAULT_NUM_FRAMES (1) #define DEFAULT_NUM_CYCLES (1) #define DEFAULT_EXPTIME (100*1000*1000) //ns diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 63bce4c5f..ad06b4102 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -9,4 +9,4 @@ #define APIJUNGFRAU 0x191106 #define APIEIGER 0x191106 #define APIGOTTHARD2 0x191108 -#define APIMYTHEN3 0x191108 +#define APIMYTHEN3 0x191111