temporary solution is to restart and restop state machine many times till it works

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@635 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2013-07-16 15:11:13 +00:00
parent b5fb6be6df
commit 34af5c9be0
2 changed files with 42 additions and 21 deletions

View File

@ -1486,7 +1486,7 @@ u_int32_t runState(void) {
// State Machine // State Machine
int startStateMachine(){ int startStateMachine(){
int i;
//#ifdef VERBOSE //#ifdef VERBOSE
printf("*******Starting State Machine*******\n"); printf("*******Starting State Machine*******\n");
//#endif //#endif
@ -1497,9 +1497,26 @@ int startStateMachine(){
write_stop_sm(0); write_stop_sm(0);
write_status_sm("Started"); write_status_sm("Started");
#endif #endif
bus_w16(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
bus_w16(CONTROL_REG, 0x0);
printf("statusreg=%08x\n",bus_r(STATUS_REG)); for(i=0;i<100;i++){
//start state machine
bus_w16(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
bus_w16(CONTROL_REG, 0x0);
//verify
if(bus_r(STATUS_REG) & RUN_BUSY_BIT)
break;
else
usleep(5000);
}
if(i!=0)
printf("tried to start state machine %d times\n",i);
if(i==100){
printf("\n***********COULD NOT START STATE MACHINE***************\n");
return FAIL;
}
printf("statusreg=%08x\n",bus_r(STATUS_REG));
return OK; return OK;
} }
@ -1507,7 +1524,7 @@ int startStateMachine(){
int stopStateMachine(){ int stopStateMachine(){
int i;
//#ifdef VERBOSE //#ifdef VERBOSE
printf("*******Stopping State Machine*******\n"); printf("*******Stopping State Machine*******\n");
//#endif //#endif
@ -1515,28 +1532,32 @@ int stopStateMachine(){
write_stop_sm(1); write_stop_sm(1);
write_status_sm("Stopped"); write_status_sm("Stopped");
#endif #endif
bus_w16(CONTROL_REG, STOP_ACQ_BIT); for(i=0;i<100;i++){
bus_w16(CONTROL_REG, 0x0); //stop state machine
/* bus_w16(CONTROL_REG, STOP_ACQ_BIT);
int i; bus_w16(CONTROL_REG, 0x0);
for(i=0;i<10;i++){ usleep(5000);
if(!(bus_r(STATUS_REG)&RUNMACHINE_BUSY_BIT)){ //verify
printf("stoppped\n"); if(!(bus_r(STATUS_REG)&RUNMACHINE_BUSY_BIT))
break; break;
}else{
usleep(5000);
printf("trying to stop again\n");
bus_w16(CONTROL_REG, STOP_ACQ_BIT);
bus_w16(CONTROL_REG, 0x0);
}
} }
*/ if(i!=0)
usleep(5000); printf("tried to stop state machine %d times\n",i);
if(i==100){
printf("\n***********COULD NOT STOP STATE MACHINE***************\n");
return FAIL;
}
/*
usleep(5000);
// if (!runBusy()) // if (!runBusy())
if(!(bus_r(STATUS_REG)&RUNMACHINE_BUSY_BIT)) if(!(bus_r(STATUS_REG)&RUNMACHINE_BUSY_BIT))
return OK; return OK;
else else
return FAIL; return FAIL;
*/
printf("statusreg=%08x\n",bus_r(STATUS_REG));
return OK;
} }