5.8 DEMO8
/* -------------------------------------------------------------------- */
/* DEMO8: D/A Output without calibration */
/* Step1: Run DEMO8.EXE under DOS */
/* -------------------------------------------------------------------- */
#include "PIO.H"
void pio_da16_da(int cChannel_no,int iVal);
WORD wBase,wIrq;
int main()
{
int i,j,k;
WORD wBoards,wRetVal,t1,t2,t3,t4,t5,t6;
WORD wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice;
clrscr();
/* Step 1: find address-mapping of PIO/PISO cards */
.
.
/* Step 2: enable all D/I/O port */
outportb(wBase,0x11);
/* /RESET -> 1 */
printf("\n\n(2) A/D Output without calibration test");
printf("\n\n (a) 1.23V Voltage output to each channel");
for (i=0; i<16; i++)
{
j=1.23*16383/20.0+8192;
pio_da16_da(i,j);
}
getch();
printf("\n\n (b) 1.23mA Current output to each channel");
for (i=0; i<16; i++)
{
j=1.23*8192/20+8191;
pio_da16_da(i,j);
}
getch();
outportb(wBase+5,0);
/* disable all interrupt */
outportb(wBase+3,0);
/* all D/O are Low */
outportb(wBase+2,0);
/* all AUX as D/I */
PIO_DriverClose();
}
/* -------------------------------------------------------------- */
void pio_da16_da(int iChannel_no,int iVal)
{
iVal=iVal+(iChannel_no%4)*0x4000;
/* iChannel_no : 0 - 15 */
outportb(wBase+0xf0,iVal);
/* iVal : 0x0000 - 0x3fff */
outportb(wBase+0xf4,(iVal>>8));
outportb(wBase+0xe0+4*(iChannel_no/4),0xff);
}
PIO-DA/PISO-DA Series User Manual (Ver.2.9, Feb. 2011, PMH-009-29 )
68