/**************************************************************************/ /* This program is developed by Turbo C 2.0/Borland C++3.1 */ /**************************************************************************/ /* DEMO34: P1202_Card0 Function demo. */ /* contiunous capture sacn all 32 channels with 33k.3k/sec */ /* sampling rate and save to disk */ /* The sampling rate is 8M/div, where 'div' is an inputed number. */ /**************************************************************************/ #define MYLIB #include "P1202DR.H" #include #define DATACOUNT 200 /* how many data is scan for a A/D channel */ int main() { int i,j,i1,i2,iBuf[80]; WORD wBoards,wRetVal; WORD wDIOdata; WORD wChannelStatus[32],wChannelConfig[32]; DWORD dwExact,dwOKs,dwErrors,dwScanCount,dwP1,dwP2,dwStatus; WORD wDiv,wVal,dwT,p,Val; WORD wAddrTimer,wAddrCtrl,wAddrDio,wAddrAdda; FILE *fp,*fp2; /* initiaing P1202 card and detect how many P1202 card in PC */ wRetVal=P1202_DriverInit(&wBoards); printf("Threr are %d P1202 Cards in this PC.\n",wBoards); if( wBoards==0 ) { putch(0x07); putch(0x07); putch(0x07); printf("There are no P1202 card in this PC !!!\n"); exit(0); } /* dump every P1202 card's configuration address space */ printf("The Configuration Space -> Timer Control DIO AD/DA\n"); for(i=0; i %2d",wRetVal); exit(0); } p=0; for(;;) { wVal=inport(wAddrCtrl); /* read FIFO status */ if (!(wVal&0x40)) /* FIFO is overflow */ { printf("Overflow\n"); break; } else if ((wVal&0x20)) /* 1=data ready */ { wBuf0[p++]=inport(wAddrAdda)&0x0fff; if (p>127) { p=0; fwrite(wBuf0,128,2,fp); } } } /* end of for loop */ disable_timer0(); P1202_Card0_Stop(); P1202_DriverClose(); fclose(fp); return 0; }