PCI-1202/1602/180x Series Card
Multi-Function Boards
User Manual/ Ver. 4.8/ Mar. 2015/ PMH-0014-48/ Page: 74
The source code of the
middle-trigger function
(Windows version) is given as follows:
P180x_StartScanPostTrg(…) is designed for PCI-1800/1802 series
P1202_StartScanPostTrg(…) is designed for PEX-1202 and PCI-1202 series
P1602_StartScanPostTrg(…) is designed for PCI-1602 series
WORD CALLBACK
P180X_StartScanMiddleTrg
(WORD wSampleRateDiv, DWORD dwNum, SHORT
nPriority)
{
disable_timer0();
// disable internal pacer timer
disable_timer1();
// disable external pacer timer
wVal=pic_control(0xD400);
/* 11?1 01?? ???? ???? cmd_101=start scan */
if (wVal!=0) return(wVal);
_outpw(wAddrCtrl,0xf000);
// 1. disable all external trigger
enable_timer1(wSampleRateDiv);
// 2. Sampling rate=8M/dwSampleRateDiv
_outpw(wAddrCtrl,0x6800);
// 3. B15=0,S2=0,S1=1,S0=0 --> clr FIFO
_outpw(wAddrCtrl,0xE800);
// 3. B15=1,S2=0,S1=1,S0=0 --> enable timer-1
_outpw(wAddrCtrl,0xFC00);
// 4. S2=1; S1=1; S0=1 --> wait ext signal
// create magicscan thread
InitializeCriticalSection(&MagicScan_CS);
wThreadStatus=0; wPreMid=1; wAskThreadStop=0;
// middle-trigger
hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE,
magic_scan_pre_mid_trg, NULL, 0,&dwThreadID);
SetThreadPriority(hThread,nPriority);
// can not use HI/LO alarm & digital filter
i=0;
for(;;)
{
EnterCriticalSection(&MagicScan_CS);
j=wThreadStatus;
LeaveCriticalSection(&MagicScan_CS);
if (j!=0) break;
i++; Sleep(1);
if (i>1000) return(ThreadCreateError);
}
return(NoError);
}