//DAQ.CPP - DATA ACQUISITION OF 512 SAMPLE POINTS #include "dsklib.h" //contains several header files #include "C3XMMRS.H" #include #include #define MSG_BOX 0x809900L #define SAMPLES 0x809906L #define Samples 512 // Get 512 samples from DSK char DSK_APP[]="DAQ.DSK"; //loads DAQ.DSK into DSK char DSK_EXE[]="DAQ.EXE"; //PC host void store_data(ulong *ptr1); ulong buf_0[512]; // Data buffers ulong MSG; void main(void) { MSGS err; ulong *tmp1; Detect_Windows(); if(Init_Communication(10000) != NO_ERR){ cerr << "Could not init comm" << endl; exit(-1); } // Load applications code HALT_CPU(); if((err=Load_File(DSK_APP,LOAD))!=NO_ERR) { printf("%s %s\n",DSK_APP,Error_Strg(err)); exit(0); } RUN_CPU(); tmp1 = buf_0; disable_Mtask(); HPI_STRB(0); // Wait for DSK to stop with full buffer enable_Mtask(); // If in windows background turn multitask if(HPI_ACK() == 1){ cerr << "ACK = 1" << endl; } else{ delay(10); } Release_TSlice(); if(getmem(0x809A00L,Samples/2, tmp1)!=NO_ERR){ cerr << "Error reading samples" << endl; } store_data(tmp1); // xor undraw the old data vectors enable_Mtask(); } void store_data(ulong *ptr1) { int *iptr; char buf[16]; int value; if(ptr1[0] != 0){ ofstream file("daq.dat"); (void *)iptr = ptr1; for(int i=0;i<512;i++){ value = (int)(*iptr++); file << value << "\n"; } sprintf(buf,"Value: %d\n",(int)*iptr); cout << buf; file.flush(); file.close(); } }