Elektra CPU User Manual V1.00
Page 61
13. A/D SCAN, INTERRUPT, AND FIFO OPERATION
The control bits SCANEN (scan enable) and AINTE (A/D interrupt enable) in conjunction with the
FIFO determine the behavior of the board during A/D conversions and interrupts.
At the end of an AD conversion, the 16-bit A/D data is latched into the 8-bit FIFO in an interleaved
fashion, first LSB, then MSB. A/D Data is read out of the FIFO with 2 read operations, first Base +
0 (LSB) and then Base + 1 (MSB).
When SCANEN = 1, each time an A/D trigger occurs, the board will perform an A/D conversion
on all channels in the channel range programmed in Base + 2. When SCANEN = 0, each time an
A/D trigger occurs, the board will perform a single A/D conversion and then advance to the next
channel and wait for the next trigger.
During interrupt operation (AINTE = 1), the FIFO will fill up with data until it reaches the threshold
programmed in the FIFO threshold register, and then the interrupt request will occur. If AINTE =
0, the FIFO threshold is ignored and the FIFO continues to fill up.
If the FIFO reaches its limit of 48 samples in regular mode or 256 samples in expanded FIFO
mode, then the next time an A/D conversion occurs the Overflow flag OVF will be set. In this case
the FIFO will not accept any more data, and its contents will be preserved and may be read out.
In order to clear the overflow condition, the program must reset the FIFO by writing to the
FIFORST bit in Base + 1, or a hardware reset must occur. There are two OVF bits, bit 3 at
base+3 and bit 3 at base+6 (B). Both bits are the same and are interchangeable.
In Scan mode (SCANEN = 1), the FIFO threshold should be set to a number at least equal to the
scan size and in all cases equal to an integral number of scans. For example if the scan size is 8
channels, the FIFO threshold should be set to 8, 16, 24, 32, 40, 48, or in expanded FIFO mode
256 but not less than 8. This way the interrupt will occur at the end of the scan, and the interrupt
routine can read in a complete scan or set of scans each time it runs.
In non-scan mode (SCANEN = 0), the FIFO threshold should be set to a level that minimizes the
interrupt rate but leaves enough time for the interrupt routine to respond before the next A/D
conversion occurs. Remember that no data is available until the interrupt occurs, so if the rate is
slow the delay to receive A/D data may be long. Therefore for slow sample rates the FIFO
threshold should be small. If the sample rate is high, the FIFO threshold should be high to reduce
the interrupt rate. However remember that the remaining space in the FIFO determines the time
the interrupt routine has to respond to the interrupt request. If the FIFO threshold is too high, the
FIFO may overflow before the interrupt routine responds. A good rule of thumb is to limit the
interrupt rate to no more than 1,000-2,000 per second in Windows and Linux or 10,000 per
second in DOS. Experimentation may be necessary to determine the optimum FIFO threshold for
each application.
The table on the next page describes the board’s behavior for each of the 4 possible cases of
AINTE and SCANEN. The given interrupt software behavior describes the operation of the
Diamond Systems Universal Driver software. If you write your own software or interrupt routine
you should conform to the described behavior for optimum results.
To enable
expanded FIFO
, write 0xA5 to base+1 to enable enhanced features, then set bit 0 to 1
on Page 2, base+12. Page bits are set at base+3. Writing 0xA6 to base+1 will disable enhanced
features, which will automatically disable expanded FIFO and all enhanced features at Page 1
and Page 2.
When expanded FIFO is enabled the FIFO threshold is set to a fixed 256 samples.