added the phase shift at power on part

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@79 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2012-01-06 14:06:34 +00:00
parent efb30128fd
commit d5271ecb46
3 changed files with 51 additions and 17 deletions

View File

@ -167,36 +167,46 @@ int setDAQRegister()
result=FAIL; result=FAIL;
} }
#ifdef VERBOSE #ifdef VERBOSE
printf("DAQ reg:20916770:%d\n",reg); printf("DAQ reg:20916770:%d",reg);
#endif #endif
return result; return result;
} }
int setPhaseShiftOnce(){ int setPhaseShiftOnce(){
u_int32_t addr, reg, val; u_int32_t addr, reg;
int result=OK, i,off; int result=OK, i,val,powerOn=0;
addr=MULTI_PURPOSE_REG; addr=MULTI_PURPOSE_REG;
//off=15; reg=bus_r(addr);
// mask=((0x1)<<off); #ifdef VERBOSE
printf("Multipurpose reg:%d\n",reg);
#endif
//Checking if it is power on(negative number)
if(((reg&0xFFFF0000)>>16)>0){
bus_w(addr,0x0); //clear the reg
#ifdef VERBOSE
printf("Implementing Phase Shift-Reg:%d\n",bus_r(addr));
#endif
//phase shift
for (i=1;i<PHASE_SHIFT;i++) {
bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT|PHASE_STEP_BIT));//0x2821
bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT&~PHASE_STEP_BIT));//0x2820
}
//confirming phase change by setting CHANGE_AT_POWER_ON_BIT(for later uses)
bus_w(addr,(CHANGE_AT_POWER_ON_BIT|
INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT&~PHASE_STEP_BIT));
}
reg=bus_r(addr); reg=bus_r(addr);
if(reg printf("\nREG:%d\n",reg);
reg|=((0x1)<<off);
// if(reg&
for (i=1;i<PHASE_SHIFT;i++) {
bus_w(addr,0x2821);
bus_w(addr,0x2820);
}
reg=bus_r(addr);
// bus_w(addr, 1<<
return result; return result;
} }
//aldos function volatile (not needed) //aldos function volatile (not needed)
u_int16_t bus_w16(u_int32_t offset, u_int16_t data) { u_int16_t bus_w16(u_int32_t offset, u_int16_t data) {
u_int16_t *ptr1; u_int16_t *ptr1;

View File

@ -189,5 +189,29 @@
#define OUTBUF_OFF 0 #define OUTBUF_OFF 0
#define OUTBUF_MASK 1 #define OUTBUF_MASK 1
/* multi purpose register */
#define PHASE_STEP_BIT 0x00000001
#define PHASE_STEP_OFFSET 0
#define READOUT_BUSY_BIT 0x00000002
#define FIFOTEST_BUSY_BIT 0x00000004
#define WAITING_FOR_TRIGGER_BIT 0x00000008
#define DELAYBEFORE_BIT 0x00000010
#define SW1_BIT 0x00000020
#define SW1_OFFSET 5
#define ENET_RESETN_BIT 0x00000800
#define ENET_RESETN_OFFSET 11
#define INT_RSTN_BIT 0x00002000
#define INT_RSTN_OFFSET 13
#define CHANGE_AT_POWER_ON_BIT 0x00008000
#define CHANGE_AT_POWER_ON_OFFSET 15
#endif #endif

View File

@ -68,7 +68,7 @@ int init_detector( int b) {
initDetector(); initDetector();
printf("\ninitdetector done! \n"); printf("\ninitdetector done! \n");
setDummyRegister(); setDummyRegister();
// setPhaseShiftOnce(); setPhaseShiftOnce();
setDAQRegister(); setDAQRegister();
setSettings(GET_SETTINGS); setSettings(GET_SETTINGS);