The demo program for D/A is given as follows:
WORD P180X_Da(WORD wDaChannel, WORD wDaVal)
{
z
P1202_Da(…) for PCI-1202
z
P1602_Da(…) for PCI-1602
if (wDaChannel==0)
/* channel 0 */
{
outport(wAddrAdda,wDaVal);
return(NoError);
}
else if (wDaChannel==1) /* channel_1 */
{
outport((wA4),wDaVal);
return(NoError);
}
else return(DaChannelError);
}
The demo program of software trigger A/D conversion is given as follows:
WORD P180X_AdPollingHex(Word *AdVal)
{
z
P1202_AdPollingHex(…) for PCI-1202
z
P1602_AdPollingHex(…) for PCI-1602
WORD wVal, wTime ;
//Clear FIFO
outport(wAddrCtrl,0x2000); // B15=0=clear FIFO, B13=1=not MagicScan controller cmd
outport(wAddrCtrl,0xA000); // B15=1=no clear FIFO, B13=1= not MagicScan controller cmd
outport((WORD)(wA4),0xffff); /* generate a software trigger pulse */
wTime=0;
for (;;)
{
wVal=inport(wAddrCtrl)&0x20; // wait for ready signal
if (wVal!=0) break;
/* if B4==1
Æ
A/D data ready */
wTime++;
if (wTime>32760) return(AdPollingTimeOut);
}
AdVal=inport(wAddrAdda)&0x0fff; /*
Read the available A/D data from FIFO */
return(NoError); /* 0x0fff for 12-bit ADC, 0xffff for 16-bit ADC */
}
PCI-1202/1602/1800/1802 Hardware User’s Manual
(Ver. 4.2, Dec/2009, PMH-014-42)---- 65