Using a D/A Card With IOPL

By Alger Pike

Note: You must have a DT board to use this code Some pieces of this code are not availible due to Copyright issues. Also changes have been made to this code from its original form. If you have a DT board and would like to modify the full code as I have done then cotact DT, they will be glad to send it to you.  /*
 * PACER Subroutine Library
 * Software Support for the DT2819 and DT2919 Boards
 * Copyright (C) 1989, Data Translation Inc. All rights reserved.
 * This software is furnished to purchaser under a license for
 * use on a single computer system and can be copied (with the inclusion
 * of DTI's copyright notice) only for use in such system, except as may
 * be otherwise provided in writing by Data Translation Inc. 100 Locke
 * Drive, Marlborough, Massachusetts 01752-1192.
 * The information in this document is subject to change without notice
 * and should not be construed as a commitment by Data Translation
 * Inc. Data Translation Inc. assumes no responsibility for any errors
 * that may appear in this document.
 * Data Translation cannot assume any responsibility for the use of any
 * portion of this software on any equipment not supplied by Data
 * Translation Inc.
 * Data Tanslation Engineering
 * PACER Subroutine Library
 * Date: 8/1/89
 * Author: Andrew Krause
 * System: IBM AT or IBM PS/2
 * Libraries Linked:
 * Modules:       PACERDEF.H              definition header file
 * PACERERR.H             error number header file
 * ** PACER.C                subroutines
 * PACER_IO.C             IO code mostly inline assembley
 * PA_UTIL.C              Time of day and utility code
 * Program: PACER Subroutine Library
 * Module: Pacer.c
 * Version      Date            Changes
 * V00.00       1-Jul-89        started
 * V00.10       1-Aug-89        first draft
 * V02.00       4-April-93      Engineering rewrite
 * PA_UTIL.C              Time of day and utility code
 * Program: PACER Subroutine Library
 * Module: Pacer.c
 * Version      Date            Changes
 * V00.00       1-Jul-89        started
 * V00.10       1-Aug-89        first draft
 * V02.00       4-April-93      Engineering rewrite
 * V00.00       1-Jul-89        started
 * V00.10       1-Aug-89        first draft
 * V02.00       4-April-93      Engineering rewrite

/*#include "inter.h"*/
 * 1) define INCL_DOS
 * 2) include 
 * 3) include 
 * 4) include 
 * 5) include 
 * 6) include "pacerdef.h"
 * 7) include "pacersrc.h"


 * 1) define FALSE 0
 * 2) define TRUE 1


 * 1) ifndef WORD
 * 2) define WORD USHORT
 * 3) endif


 * 1) ifndef outp
 * 2) define outp OUTP8
 * 3) endif


 * 1) ifndef inp
 * 2) define inp INP8
 * 3) endif

/* Base I/O address for the DT2X18. */

static int BASE=0x230;

/* Interrupt selected for the DT2X18. */

static int INT_LEVEL=0;

/* Array of interrupts for POS mapping from DT2918. */

static char POS_INTS[8]={0,7,5,4,12,11,10,9};

/* Check that a DT2819 or DT2919 exists at the Base address used in the program by examing READ\WRITE\VERIFY operations to the latched enable bit in the Control\Status Register. */

int PA_BOARD_EXIST ( void ) { int data; int write_data; int read_data; data = INP8 ( BASE + CONTROL_STATUS ); if ( data == 0xff ) return( boardNotFoundErr ); if ( data & 2 ) return( noErr ); if ( data & 1 ) write_data = ( data & 1 ); else write_data = ( data | 1 ); OUTP8 ( BASE + CONTROL_STATUS, write_data ); read_data = INP8 ( BASE + CONTROL_STATUS ); OUTP8 ( BASE + CONTROL_STATUS, data ); if ( read_data != write_data ) return( boardNotFoundErr ); return(noErr); }

/* Returns 0 for noErr or errWriting. */

int PA_WRITE_CONTROL( USHORT and_value, USHORT or_value ) {    int data; int data_read; int status_bits = 0x5d; data = INP8 ( BASE + CONTROL_STATUS ); data &= and_value; data |= or_value; data &= status_bits; OUTP8( BASE + CONTROL_STATUS, data ); data_read = INP8 ( BASE + CONTROL_STATUS ); if ( ( data_read & status_bits ) != data ) return( errWriting ); return( noErr ); }  Using IOPL calls is fairly staight foreward. All you need to do is replace existing INP, OUTP,etc. by the appropriate IOPL call INP8, OUTP8, INP16, OUTP16, etc. Link in the Lib and the you are set. See the previous page to download an IOPL dll that I wrote that works with all compilers.

Download pacer.zip the DLL I wrote to do IOPL calls