diff --git a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c b/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c index 404f784bf..18f74c469 100755 --- a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c @@ -1,4 +1,4 @@ -#define TESTADC +//#define TESTADC #include "server_defs.h" @@ -50,7 +50,7 @@ int phase_shift=0;//DEFAULT_PHASE_SHIFT; int ipPacketSize=DEFAULT_IP_PACKETSIZE; int udpPacketSize=DEFAULT_UDP_PACKETSIZE; -u_int32_t clkDivider[2]={32,32}; +u_int32_t clkDivider[2]={160,32}; int ififostart, ififostop, ififostep, ififo; @@ -365,21 +365,28 @@ u_int32_t readin(int modnum) { u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val, int trig) { - u_int32_t vv=reg<1) return -1; + if (ic==1 && d>40) + return -1; + + if (d>160) + return -1; + + if (tot>510) + return -1; + + if (tot<1) + return -1; - l=tot/2; - h=l; - if (tot>2*l) { - h=l+1; - odd=1; - } - printf("Low is %d, High is %d\n",l,h); - if (l>255 || h>255) - return -1; //values out of range + clkDivider[ic]=d; + bus_w(PLL_CNTRL_REG,(1<2*l) { + h=l+1; + odd=1; + } + printf("Counter %d: Low is %d, High is %d\n",i, l,h); + + + val= (i<<18)| (odd<<17) | l | (h<<8); + + printf("Counter %d, val: %08x\n", i, val); + + setPllReconfigReg(PLL_C_COUNTER_REG, val,0); + usleep(10000); + } + - setPllReconfigReg(PLL_C_COUNTER_REG, val,1); setPllReconfigReg(PLL_START_REG, 1,1); usleep(100000); bus_w(PLL_CNTRL_REG, 0); - clkDivider[ic]=d; return clkDivider[ic]; } @@ -504,6 +536,11 @@ int phaseStep(int st, int ic){ /* ic=0; */ /* st*=-1; */ /* } */ + + bus_w(PLL_CNTRL_REG,(1<