jungfrau server: fixes for current source and configuring chipv1.1

This commit is contained in:
maliakal_d 2021-10-07 11:27:02 +02:00
parent fcfbb7040a
commit 2c6793633e
3 changed files with 39 additions and 18 deletions

View File

@ -470,6 +470,7 @@ void setupDetector() {
initReadoutConfiguration(); initReadoutConfiguration();
// Initialization of acquistion parameters // Initialization of acquistion parameters
disableCurrentSource();
setSettings(DEFAULT_SETTINGS); setSettings(DEFAULT_SETTINGS);
setGainMode(DEFAULT_GAINMODE); setGainMode(DEFAULT_GAINMODE);
@ -499,7 +500,6 @@ void setupDetector() {
setFilterResistor(DEFAULT_FILTER_RESISTOR); setFilterResistor(DEFAULT_FILTER_RESISTOR);
setFilterCell(DEFAULT_FILTER_CELL); setFilterCell(DEFAULT_FILTER_CELL);
} }
disableCurrentSource();
setReadNRows(MAX_ROWS_PER_READOUT); setReadNRows(MAX_ROWS_PER_READOUT);
} }
@ -1106,10 +1106,8 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
setDAC(specialDacs[i], dacVals[i], 0); setDAC(specialDacs[i], dacVals[i], 0);
} }
// if chip 1.1, and power chip on, configure chip // if chipv1.1 and powered on
if (getChipVersion() == 11 && powerChip(-1)) {
configureChip(); configureChip();
}
return getSettings(); return getSettings();
} }
@ -1749,16 +1747,25 @@ int isChipConfigured() {
} }
void configureChip() { void configureChip() {
// only for chipv1.1 // only for chipv1.1 and chip is powered on
if (getChipVersion() == 11) { if (getChipVersion() == 11 && powerChip(-1)) {
LOG(logINFOBLUE, ("Configuring chip\n")); 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 // waiting 500 ms before configuring chip
usleep(500 * 1000); usleep(500 * 1000);
// write same register values back to configure chip // write same register values back to configure chip
bus_w(CONFIG_V11_REG, bus_r(CONFIG_V11_REG)); 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; chipConfigured = 1;
} }
} }
@ -2205,11 +2212,18 @@ void setFilterCell(int iCell) {
void disableCurrentSource() { void disableCurrentSource() {
LOG(logINFO, ("Disabling Current Source\n")); LOG(logINFO, ("Disabling Current Source\n"));
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_ENBL_MSK);
// default values for current source // 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_LSB_REG, BIT32_MASK);
bus_w(CRRNT_SRC_COL_MSB_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) { 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)); fix, (long long int)select, normal));
} }
disableCurrentSource(); disableCurrentSource();
LOG(logINFO, ("\tSetting current source parameters\n"));
// fix // fix
if (fix) { if (fix) {
LOG(logINFO, ("\tEnabling fix\n"));
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_CRRNT_SRC_CLMN_FIX_MSK); bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_CRRNT_SRC_CLMN_FIX_MSK);
} else { } else {
LOG(logINFO, ("\tDisabling fix\n"));
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_CLMN_FIX_MSK); bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_CLMN_FIX_MSK);
} }
if (getChipVersion() == 10) { if (getChipVersion() == 10) {
// select // 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) & ~DAQ_CRRNT_SRC_CLMN_SLCT_MSK);
bus_w(DAQ_REG, bus_w(DAQ_REG,
bus_r(DAQ_REG) | ((select << DAQ_CRRNT_SRC_CLMN_SLCT_OFST) & 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 { } else {
// select // select
LOG(logINFO, ("\tSetting selection\n"))
set64BitReg(select, CRRNT_SRC_COL_LSB_REG, CRRNT_SRC_COL_MSB_REG); set64BitReg(select, CRRNT_SRC_COL_LSB_REG, CRRNT_SRC_COL_MSB_REG);
// normal // normal
if (normal) { if (normal) {
LOG(logINFO, ("\tEnabling normal\n"))
bus_w(CONFIG_V11_REG, bus_w(CONFIG_V11_REG,
bus_r(CONFIG_V11_REG) & ~CONFIG_V11_CRRNT_SRC_LOW_MSK); bus_r(CONFIG_V11_REG) & ~CONFIG_V11_CRRNT_SRC_LOW_MSK);
} else { } else {
LOG(logINFO, ("\tEnabling low\n"))
bus_w(CONFIG_V11_REG, bus_w(CONFIG_V11_REG,
bus_r(CONFIG_V11_REG) | CONFIG_V11_CRRNT_SRC_LOW_MSK); 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 // acquisition
// enabling current source // 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); bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_CRRNT_SRC_ENBL_MSK);
configureChip();
} }
int getCurrentSource() { int getCurrentSource() {

View File

@ -10,4 +10,4 @@
#define APIMYTHEN3 0x211005 #define APIMYTHEN3 0x211005
#define APIMOENCH 0x210927 #define APIMOENCH 0x210927
#define APIEIGER 0x211005 #define APIEIGER 0x211005
#define APIJUNGFRAU 0x211006 #define APIJUNGFRAU 0x211007