/****************************************************************************** * Program to use the experimental DAC, ver. beta 2.01 * * * * by * * * * L. Padilla (e-mail: padilla at domain "gae ucm es") * * * * Madrid, 1995 - 1997 * * * * Latest version at http://www.gae.ucm.es/~padilla/extrawork/dac.c * ******************************************************************************/ #define DPPORT 0x0378 /* Data parallel port 1. */ #define CPPORT 0x037A /* Control parallel port 1. */ #define CSPORT 0x03FC /* Control serial port 1. */ #define SIZE 1500000uL /* Bytes to record. */ #include #include #include main (void) { unsigned char byte, delay; register unsigned char i; register unsigned long j; clock_t time3, time4; FILE * file; printf ("\n"); outp (CPPORT, 0xFB); /* Sets to 0v control pins of parallel port 1 to avoid possible drifts. */ outp (CSPORT, 0x00); /* Sets to around -11v pin number 4 of serial port 1 to feed polarization voltage. */ outp (DPPORT, 0x80); /* Sets initial voltage of DAC (half way). */ printf ("Enter delay (recommended 74) (0 - 255): "); /* To match play and record times */ scanf ("%u", & delay); /* Waits for enter. */ /* delay = 74; /* */ time3 = clock (); file = fopen ("sonido.dat", "rb"); /* In RAM disk (highly recommended) */ for (j = 0uL; j < SIZE; j++) { for (i = 0u; i < delay; i++) /* Delay loop. */ ; fread (& byte, 1, 1, file); /* Reads data from file. */ byte = ~ byte; /* Inverts, setting right value, otherwise only exists a phase difference of 180 deg. */ outp (DPPORT, byte); /* Plays digitalization with DAC, but speed will be incorrect. */ /* printf ("%2.2X\n", byte); /* Prints digitalized value (hex). */ /* printf ("%u %u\n", j, byte); /* Prints digitalized value (dec). */ } time4 = clock (); fclose (file); outp (DPPORT, 0x00); /* Sets to 0v the 8 data pins of parallel port 1. */ printf ("Time of play: %lf\n", (float) (time4 - time3)/(float) CLK_TCK); printf ("\n"); return 0; }