changed dac values, fixed settings bug of not looking at nchan,nchips, , fixed clock divider, changed usleep in configuremac

This commit is contained in:
Dhanya Maliakal
2016-11-03 09:16:01 +01:00
parent 754a4f8bdc
commit 0aecad6644
4 changed files with 31 additions and 23 deletions

View File

@ -90,7 +90,7 @@ u_int32_t progressMask=0;
int phase_shift=0;//DEFAULT_PHASE_SHIFT;
int ipPacketSize=DEFAULT_IP_PACKETSIZE;
int udpPacketSize=DEFAULT_UDP_PACKETSIZE;
int clockdivider;
int clockdivider = 20;
/*
#ifndef NEW_PLL_RECONFIG
u_int32_t clkDivider[2]={32,16};
@ -539,7 +539,6 @@ u_int32_t adcPipeline(int d) {
if (d>=0){
printf("Setting ADC Pipeline to 0x%x\n",d);
bus_w(ADC_PIPELINE_REG, d);
clockdivider = d;
}
return bus_r(ADC_PIPELINE_REG);
@ -1504,12 +1503,12 @@ int configureInterface(uint32_t destip,uint64_t destmac,uint64_t sourcemac,int
#endif
bus_w(CONTROL_REG,GB10_RESET_BIT);
sleep(1);
usleep(500 * 1000);
bus_w(CONTROL_REG,0);
usleep(10000);
usleep(10* 1000);
bus_w(CONFIG_REG,conf | GB10_NOT_CPU_BIT);
printf("System status register is %08x\n",bus_r(SYSTEM_STATUS_REG));
usleep(500 * 1000);
return 0; //any value doesnt matter - dhanya
}
@ -1550,7 +1549,7 @@ int configureMAC(uint32_t destip,uint64_t destmac,uint64_t sourcemac,int source
bus_w(CONTROL_REG,GB10_RESET_BIT);
bus_w(CONTROL_REG,0);
usleep(10000);
usleep(10 * 1000);
bus_w(CONFIG_REG,conf | GB10_NOT_CPU_BIT);
printf("System status register is %08x\n",bus_r(SYSTEM_STATUS_REG));
return OK;

View File

@ -133,6 +133,8 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
/* #endif */
destMod->serialnumber=srcMod->serialnumber;
}
/*
if ((srcMod->nchip)>(destMod->nchip)) {
printf("Number of chip of source is larger than number of chips of destination\n");
return FAIL;
@ -141,6 +143,8 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
printf("Number of channels of source is larger than number of channels of destination\n");
return FAIL;
}
*/
if ((srcMod->ndac)>(destMod->ndac)) {
printf("Number of dacs of source is larger than number of dacs of destination\n");
return FAIL;
@ -153,8 +157,8 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
#ifdef VERBOSE
printf("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac);
printf("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc);
printf("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip);
printf("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan);
//printf("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip);
//printf("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan);
#endif
@ -162,8 +166,8 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
destMod->ndac=srcMod->ndac;
destMod->nadc=srcMod->nadc;
destMod->nchip=srcMod->nchip;
destMod->nchan=srcMod->nchan;
// destMod->nchip=srcMod->nchip;
//destMod->nchan=srcMod->nchan;
if (srcMod->reg>=0)
destMod->reg=srcMod->reg;
#ifdef VERBOSE
@ -1081,7 +1085,7 @@ int initMCBregisters(int cm, int imod){
}
int initModulebyNumber(sls_detector_module myMod) {
printf("\nInitializing Module\n");
int nchip,nchan;//int ichip, nchip, ichan, nchan;
int im, modmi,modma;
// int ft, cae, ae, coe, ocoe, counts, chanreg;
@ -1110,6 +1114,7 @@ int initModulebyNumber(sls_detector_module myMod) {
}
//printf("ndac:%d\n",NDAC);
for (idac=0; idac<NDAC; idac++){
retval = setDac(idac,(myMod.dacs)[idac]);
if(retval ==(myMod.dacs)[idac])
@ -1128,6 +1133,8 @@ int initModulebyNumber(sls_detector_module myMod) {
}
//setting the conf gain and the settings register
setSettings(myMod.reg,imod);
printf("Done Initializing Module\n");
return thisSettings;
}

View File

@ -124,15 +124,15 @@ int init_detector(int b) {
printf("Setting Default Dac values\n");
enum dacNames{VB_COMP,VDD_PROT,VIN_COM,VREF_PRECH,VB_PIXBUF,VB_DS,VREF_DS,VREF_COMP};
int retval = -1;
int dacvalues[14][2]={
{VB_DS, 1000},
int dacvalues[8][2]={
{VB_COMP, 1220},
{VB_PIXBUF, 750},
{VREF_DS, 480},
{VREF_COMP, 400},
{VREF_PRECH,1550},
{VIN_COM, 1053},
{VDD_PROT, 3000},
{VIN_COM, 1053},
{VREF_PRECH,1450},
{VB_PIXBUF, 750},
{VB_DS, 1000},
{VREF_DS, 480},
{VREF_COMP, 420},
};
for(i=0;i<8;++i){
retval=setDac(dacvalues[i][0], dacvalues[i][1]);
@ -144,6 +144,9 @@ int init_detector(int b) {
printf("\nPowering on the chip\n");
bus_w(POWER_ON_REG,0x1);
/* Only once */
bus_w(CONFGAIN_REG,0x0);
printf("Resetting ADC\n");
writeADC(ADCREG1,0x3); writeADC(ADCREG1,0x0);
writeADC(ADCREG2,0x40);
@ -1456,9 +1459,9 @@ int set_module(int file_des) {
myModule.nchan=NCHAN*NCHIP;
myModule.nadc=NADC;
#ifdef VERBOSE
//#ifdef VERBOSE
printf("Setting module\n");
#endif
//#endif
ret=receiveModuleGeneral(file_des, &myModule, 0); //0 is to receive partially (without trimbits etc.)
@ -1468,9 +1471,9 @@ int set_module(int file_des) {
ret=FAIL;
#ifdef VERBOSE
//#ifdef VERBOSE
printf("module number is %d,register is %d, nchan %d, nchip %d, ndac %d, nadc %d, gain %f, offset %f\n",myModule.module, myModule.reg, myModule.nchan, myModule.nchip, myModule.ndac, myModule.nadc, myModule.gain,myModule.offset);
#endif
//#endif
if (ret==OK) {
if (myModule.module>=getNModBoard()) {
@ -2467,7 +2470,6 @@ int send_update(int file_des) {
retval=setExposureTime(tns);
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
retval=setPeriod(tns);
cprintf(RED,"updated frame period from %lld tns:%d\n", (long long int)retval, tns);
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
retval=setDelay(tns);
n = sendDataOnly(file_des,&retval,sizeof(int64_t));