/*--------------------------------------------------------------*/ /* Operational MODE Data Acquisition Programing Sample */ /* ****Multi Buffer Version**** */ /* Big Endian, 32bit(VME Double Word Access) */ /* Draft Revision 1.0a.............June 29, 2005 HIRAYAMA */ /*------------- */ /* VME_BASE : VME_BASE address (Default 0x800000) */ /* DPtop : Dual Port Memory top Address(VME_BASE+$60000+$11F00) */ /* Pcnt : Pcounter */ /* RunS : Run Status */ /* TRC : Time range count */ /* Mid : Module ID */ /* CE00 : CH_Enable(#31(MSB)-#00(LSB)) */ /* CE32 : CH_Enable(#63(MSB)-#32(LSB)) */ /* Num : Number of partitions */ /* Icnt : Icounter */ /* Scnt : Scounter */ /* RecDB : Recording data buffer */ /* Astr : AMT Status */ /*--------------------------------------------------------------*/ typedef volatile unsigned long DWORD; typedef DWORD * DWORDP; /*RunStatus*/ struct sample { unsigned : 1; /* Not Used */ unsigned start_me : 1; /* start mesurement */ unsigned common_mode : 1; /* common start/stop */ unsigned edge_detect : 2; /* edge detection */ unsigned sub_offset : 2; /* subtract offset */ unsigned mesure_cont : 1; /* mesrement control */ unsigned :20; /* Not Used */ unsigned width_sele : 3; /* width select */ unsigned : 1; /* Not Used */ } ; union { unsigned long int uliRUN_Data; struct sample RUN_Bits; } RUN_Format; #define AMTStatusEND 0x02 DWORDP Pcnt, RunS, TRC, Mid, CE00, CE32, Icnt. Scnt, RecDB, Astr, ReadAddr, WriteAddr; DPtop = VME_Base + 0x60000 + 0x11F00; Pcnt = (DWORDP) (DPtop); RunS = (DWORDP) (DPtop + 0x4); TRC = (DWORDP) (DPtop + 0x08); Mid = (DWORDP) (DPtop + 0x0c); CE00 = (DWORDP) (DPtop + 0x10); CE32 = (DWORDP) (DPtop + 0x14); Num = (DWORDP) (DPtop + 0x018); Icnt = (DWORDP) (DPtop + 0x01c); Astr = (DWORDP) (DPtop + 0x0e4); Scnt = (DWORDP) (DPtop + 0x0e8); RecDB = (DWORDP) (DPtop + 0x0100); /*!!!! Please fill "XXXXXX" !!!!*/ WriteAddr = (DWORDP)(XXXXXX); /* WriteAddr is destination of save data address */ /*----Setting Run Status Parameter----*/ RUN_Format.uliRUN_Data=0; RUN_Format.RUN_Bits.common_mode=0x0; /* Set "common start mode" */ RUN_Format.RUN_Bits.edge_detect=0x0; /* Set rising */ RUN_Format.RUN_Bits.sub_offset=0x0; /* no offset */ RUN_Format.RUN_Bits.mesure_cont=0x0; /* TRG mode */ RUN_Format.RUN_Bits.width_sele=0x0; /* width resolution 0.78125ns */ *TRC = 0x7ea; /* Time Range Count setting about 50us */ *Mid = 0x0; /* Module ID=0 */ *CE00 = 0x0FFFFFFFF; /* all CH enable */ *CE32 = 0x0FFFFFFFF; /* all CH enable */ *Num = 0x04; /* Number of partitions=4 Single Buffer */ /*----Prepare for start measurement----*/ RUN_Format.RUN_Bits.start_me=0x1; /* start measurement(Run Status)=1 */ *RunS = RUN_Format.uliRUN_Data; (*Pcnt)++; /* Pcount++ update Pcount */ /*----Start Measurement----*/ while(1){ /*---about Inputdata()---*/ /* In multi buffer, we have some buffers, so it is almost no meaning that Input Data is in this Loop. */ /* If you control Input Data process by another program (ex:GP-IB), */ /* you should make a routin of Input Data at that program part. */ while(((*Scnt&0x03)==(*Icnt&0x03)) && (*Astr!=AMTStatusEND)){ /* waiting until Scounter not equal Icounter */ if( KeyHit() ){ RUN_Format.RUN_Bits.start_me=0; /*start mesurement=0*/ break; } } if(RUN_Format.RUN_Bits.start_me==0){ break; } /*----Read Hit Data----*/ ReadAddr = (DWORDP) (RecDB+(0x0C00 * (*Icnt&0x03)); /* Start address of read data */ do{ *WriteAddr++ = *ReadAddr++; /* saving data */ }while((*ReadAddr&0x0ffff0000)!=0x55550000 ); /* if "end of data" value, reading data finish */ (*Icnt)++; } /*----quit of measurement----*/ *RunS = RUN_Format.uliRUN_Data;