diff --git a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c b/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c index 148850fab..204ff3dde 100755 --- a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c @@ -1927,7 +1927,7 @@ u_int16_t* fifo_read_event() #endif dma_memcpy(now_ptr,values ,dataBytes); - + printf("-"); //memcpy(now_ptr,values ,dataBytes); //this reads the fifo twice... #ifdef VERYVERBOSE @@ -1958,6 +1958,7 @@ u_int16_t* fifo_read_event() printf("lookatmereg=x%x\n",t); #endif return ram_values; + printf("\n"); } @@ -2740,12 +2741,16 @@ uint64_t writePatternWord(int addr, uint64_t word) { return readPatternWord(addr); } uint64_t writePatternIOControl(uint64_t word) { - if (word>=0)set64BitReg(word,PATTERN_IOCTRL_REG_LSB,PATTERN_IOCTRL_REG_MSB); + if (word!=0xffffffffffffffff) { + // printf("%llx %llx %lld",get64BitReg(PATTERN_IOCTRL_REG_LSB,PATTERN_IOCTRL_REG_MSB),word); + set64BitReg(word,PATTERN_IOCTRL_REG_LSB,PATTERN_IOCTRL_REG_MSB); + // printf("************ write IOCTRL (%x)\n",PATTERN_IOCTRL_REG_MSB); + } return get64BitReg(PATTERN_IOCTRL_REG_LSB,PATTERN_IOCTRL_REG_MSB); } uint64_t writePatternClkControl(uint64_t word) { - if (word>=0)set64BitReg(word,PATTERN_IOCLKCTRL_REG_LSB,PATTERN_IOCLKCTRL_REG_MSB); + if (word!=0xffffffffffffffff) set64BitReg(word,PATTERN_IOCLKCTRL_REG_LSB,PATTERN_IOCLKCTRL_REG_MSB); return get64BitReg(PATTERN_IOCLKCTRL_REG_LSB,PATTERN_IOCLKCTRL_REG_MSB); } @@ -2789,14 +2794,24 @@ int setPatternLoop(int level, int *start, int *stop, int *n) { printf("level %d start %x stop %x nl %d\n",level, *start, *stop, *n); lval=bus_r(areg); +/* printf("l=%x\n",bus_r16(areg)); */ +/* printf("m=%x\n",bus_r16_m(areg)); */ + + + + + printf("lval %x\n",lval); if (*start==-1) *start=(lval>> ASTART_OFFSET) & APATTERN_MASK; printf("start %x\n",*start); + if (*stop==-1) *stop=(lval>> ASTOP_OFFSET) & APATTERN_MASK; - printf("stop %x\n",*start); + printf("stop %x\n",*stop); + lval= ((*start & APATTERN_MASK) << ASTART_OFFSET) | ((*stop & APATTERN_MASK) << ASTOP_OFFSET); printf("lval %x\n",lval); + bus_w(areg,lval); printf("lval %x\n",lval); @@ -2822,9 +2837,14 @@ int setPatternWaitAddress(int level, int addr) { default: return -1; }; - printf ("%d addr %x\n",level,addr); + // printf("BEFORE *********PATTERN IOCTRL IS %llx (%x)\n",writePatternIOControl(-1), PATTERN_IOCTRL_REG_MSB); + + // printf ("%d addr %x (%x)\n",level,addr,reg); if (addr>=0) bus_w(reg, addr); - printf ("%d addr %x %x\n",level,addr, bus_r(reg)); + // printf ("%d addr %x %x (%x) \n",level,addr, bus_r(reg), reg); + + // printf("AFTER *********PATTERN IOCTRL IS %llx (%x)\n",writePatternIOControl(-1), PATTERN_IOCTRL_REG_MSB); + return bus_r(reg); } @@ -2920,8 +2940,8 @@ int setDacRegister(int dacnum,int dacvalue) { } - printf("Dac register %x wrote %08x\n",(128+dacnum/2)<<11,val); - bus_w((128+dacnum/2)<<11, val); + printf("Dac register %x wrote %08x\n",(DAC_REG_OFF+dacnum/2)<<11,val); + bus_w((DAC_REG_OFF+dacnum/2)<<11, val); return getDacRegister(dacnum); @@ -2931,8 +2951,8 @@ int getDacRegister(int dacnum) { int retval; - retval=bus_r((128+dacnum/2)<<11); - printf("Dac register %x read %08x\n",(128+dacnum/2)<<11,retval); + retval=bus_r((DAC_REG_OFF+dacnum/2)<<11); + printf("Dac register %x read %08x\n",(DAC_REG_OFF+dacnum/2)<<11,retval); if (dacnum%2) return (retval>>16)&0xffff; else diff --git a/slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServer b/slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServer index fb664cf73..3cd6737ee 100755 Binary files a/slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServer and b/slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServer differ diff --git a/slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServer.gdb b/slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServer.gdb index e7ee343fc..cd7df5a3d 100755 Binary files a/slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServer.gdb and b/slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServer.gdb differ diff --git a/slsDetectorSoftware/jungfrauDetectorServer/registers_m.h b/slsDetectorSoftware/jungfrauDetectorServer/registers_m.h index f0e1e11d7..abe4cc9a7 100755 --- a/slsDetectorSoftware/jungfrauDetectorServer/registers_m.h +++ b/slsDetectorSoftware/jungfrauDetectorServer/registers_m.h @@ -113,7 +113,12 @@ #define DAC_REG 64<<11//0x17<<11// control the dacs //ADC #define ADC_WRITE_REG 65<<11//0x18<<11 -#define ADC_SYNC_REG 66<<11//0x19<<11 +//#define ADC_SYNC_REG 66<<11//0x19<<11 +//#define HV_REG 67<<11//0x20<<11 + +#define ADCCLK_MASK_REG 66<<11 +#define ADC_INVERSION_REG 66<<11 + //#define MUTIME_REG 0x1a<<11 //temperature #define TEMP_IN_REG 0x1b<<11 @@ -123,7 +128,6 @@ #define ENET_CONF_REG 0x1e<<11 //#define WRTSE_SHAD_REG 0x1f<<11 //HV -#define HV_REG 67<<11//0x20<<11 #define DUMMY_REG 68<<11//0x21<<11 @@ -251,7 +255,8 @@ #define PATTERN_IOCTRL_REG_LSB 108<<11 -#define PATTERN_IOCTRL_REG_MSB 109<<12 +#define PATTERN_IOCTRL_REG_MSB 109<<11 + #define PATTERN_IOCLKCTRL_REG_LSB 110<<11 #define PATTERN_IOCLKCTRL_REG_MSB 111<<11 #define PATTERN_IN_REG_LSB 112<<11 @@ -263,15 +268,15 @@ #define PATTERN_WAIT2_TIME_REG_LSB 118<<11 #define PATTERN_WAIT2_TIME_REG_MSB 119<<11 - -#define DAC_0_1_VAL_REG 128<<11 -#define DAC_2_3_VAL_REG 129<<11 -#define DAC_4_5_VAL_REG 130<<11 -#define DAC_6_7_VAL_REG 131<<11 -#define DAC_8_9_VAL_REG 132<<11 -#define DAC_10_11_VAL_REG 133<<11 -#define DAC_12_13_VAL_REG 134<<11 -#define DAC_14_15_VAL_REG 135<<11 +#define DAC_REG_OFF 120 +#define DAC_0_1_VAL_REG 120<<11 +#define DAC_2_3_VAL_REG 121<<11 +#define DAC_4_5_VAL_REG 122<<11 +#define DAC_6_7_VAL_REG 123<<11 +#define DAC_8_9_VAL_REG 124<<11 +#define DAC_10_11_VAL_REG 125<<11 +#define DAC_12_13_VAL_REG 126<<11 +#define DAC_14_15_VAL_REG 127<<11 diff --git a/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.c b/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.c index cc7227dfb..2d6380390 100755 --- a/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.c +++ b/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.c @@ -947,7 +947,7 @@ int read_register(int file_des) { int set_dac(int file_des) { //default:all mods - int retval; + int retval, retval1; int ret=OK; int arg[3]; enum dacIndex ind; @@ -1032,8 +1032,10 @@ int set_dac(int file_des) { if (mV) { if (val>2500) val=-1; + printf("%d mV is ",val); if (val>0) val=16535*val/2500; + printf("%d DACu\n", val); } else if (val>16535) val=-1; @@ -1057,9 +1059,13 @@ int set_dac(int file_des) { /* else if ((retval-val)<=3 || val==-1) */ /* ret=OK; */ - if (mV) - retval=2500*val/16535; - + if (mV) { + + printf("%d DACu is ",retval); + retval1=2500*retval/16535; + printf("%d mV \n",retval1); + } else + retval1=retval; } #endif @@ -1081,6 +1087,7 @@ int set_dac(int file_des) { if (ret!=FAIL) { /* send return argument */ n += sendDataOnly(file_des,&retval,sizeof(retval)); + n += sendDataOnly(file_des,&retval1,sizeof(retval1)); } else { n += sendDataOnly(file_des,mess,sizeof(mess)); } diff --git a/slsDetectorSoftware/patternGenerator/generate.sh b/slsDetectorSoftware/patternGenerator/generate.sh index a78646dce..f7aac61c4 100755 --- a/slsDetectorSoftware/patternGenerator/generate.sh +++ b/slsDetectorSoftware/patternGenerator/generate.sh @@ -9,13 +9,22 @@ if [ "$#" -ge 2 ]; then outfile=$2 fi exe=$infile"exe" +if [ "$#" -ge 4 ]; then + exe=$4 +fi + if [ "$#" -ge 3 ]; then - exe=$3 + outfilebin=$3 fi if [ -f "$infile" ] then -gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ; ./$exe ; rm $exe +gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ; +echo compiling +$exe ; +echo cleaning +rm $exe +echo done else echo "$infile not found." fi diff --git a/slsDetectorSoftware/patternGenerator/generator.c b/slsDetectorSoftware/patternGenerator/generator.c index 1df8967b5..2f7458b65 100755 --- a/slsDetectorSoftware/patternGenerator/generator.c +++ b/slsDetectorSoftware/patternGenerator/generator.c @@ -6,12 +6,12 @@ gcc -DINFILE="\"test.p\"" -DOUTFILE="\"test.pat\"" -o test.exe generator.c ; ./t *************************************************************************/ -#include /* exit() */ -#include /* exit() */ -#include /* memset(), memcpy() */ -#include /* uname() */ +#include +#include +#include +#include #include -#include /* fork(), write(), close() */ +#include #include #include #include @@ -21,7 +21,6 @@ gcc -DINFILE="\"test.p\"" -DOUTFILE="\"test.pat\"" -o test.exe generator.c ; ./t #include #include #include -//#include #define MAXLOOPS 3 #define MAXTIMERS 3 @@ -48,8 +47,6 @@ uint64_t PAT[MAXWORDS]; int i,ii,iii,j,jj,jjj,pixx,pixy,memx,memy,muxout,memclk,colclk,rowclk,muxclk,memcol,memrow,loopcounter; -//int W[33]; -//u_int32_t W; void setstart() { start=iaddr; @@ -81,16 +78,12 @@ void setclk(int bit) { void clearbit(int bit){ uint64_t mask=1; mask=mask<