Interrupt-based analog output is useful for generating analog output values automatically at a specified rate, such as generating an analog waveform. It differs in operation from a single D/A conversion scan in that it generates output data continuously or for a specified number of samples each time the function is called. There are a number of different options that can be set for interrupt-based operations; these are explained in the interrupt-based operations chapter.
The Universal Driver function for performing interrupt-based D/A conversion scans is dscDAConvertScanInt().
Create and initialize an analog I/O interrupts structure (DSCAIOINT).
Set the entries of the sample_values buffer in the DSCAIOINT structure to the desired output codes. You must have num_conversion entries of size, WORD, in the buffer to ensure proper operation.
Call dscDAConvertScanInt() and pass it a pointer to the above-mentioned DSCAIOINT structure to begin interrupt operation. The interrupt operations will now run in a separate system thread until either they reach the maximum number of conversions specified (one-shot mode only) or they are cancelled by a call to dscCancelOp.
...
DSCB dscb;
DSCAIOINT dscaioint;
int i;
/* Step 1 */
dscaioint.num_conversions = 1024;
dscaioint.conversion_rate = 10000;
dscaioint.cycle = FALSE;
dscaioint.internal_clock = TRUE;
dscaioint.low_channel = 0;
dscaioint.high_channel = 3;
dscaioint.external_gate_enable = FALSE;
/* Step 2 */
dscaioint.sample_values = (WORD*)malloc(sizeof(WORD) * dscaioint.num_conversions);
// this will setup a square wave
for (i = 0; i < dscaioint.num_conversions; i++)
{
if ( i % 2 )
dscaioint.sample_values[i] = (WORD)4095;
else
dscaioint.sample_values[i] = (WORD)0x00;
}
/* Step 3 */
if ((result = dscDAConvertScanInt(dscb, &dscaioint)) != DE_NONE)
return result;
...
This page was last modified 00:09, 7 Aug 2009.
Copyright (c) 2004 Diamond Systems. All Rights Reserved.