3.7 Checking Interrupt Operation Status

Description

The function dscGetStatus is used to indicate the current status of any interrupt operation, including A/D sampling, D/A conversions, digital input, digital output, and user interrupts. It provides several status indicators (see the definition for the data structure DSCS on page 81 for complete details):

Operation status

Either OPTYPE_NONE (no operation or operation completed) or any bit-wise combination of INT_TYPE* (interrupt operations in progress)

Number of transfers

In one-shot mode, this is the number of input or output transfers have been completed. This is not necessarily the number of interrupts that have occurred, since if a FIFO is being used each interrupt will account for more than one transfer.

In recycle mode, this is the current position in the input/output buffer. When the buffer pointer reaches the end of the buffer, it will be reset to 0 and start counting up again.

Each individual A/D conversion in a scan counts as one transfer.

Total transfers

The total number of transfers that have occurred during this operation. In one-shot mode, total transfers is the same as number of transfers. In recycle mode, this number is not reset and should be used instead of the transfers variable for tracking the total number of conversions taken.

Overflow

During A/D sampling operations on boards with a FIFO, this indicates how many times the board's FIFO has overflowed during the current operation. During correct operation this value should always be zero. If this value is non-zero, data has been missed and the sampling rate is too high for the current system configuration.

The common convention for using this function is to start a particular interrupt function, and then go into a while loop that terminates when a specified condition has occurred, such as when a specified timeout has been reached or when the interrupt operation completes. Completion is indicated by the status indicator OP_TYPE_NONE.

Step-By-Step Instructions

Create and initialize a driver status structure (DSCS). Call dscGetStatus and pass it a pointer to this structure in order to return the current interrupt operation status. The two important elements to note in the DSCS structure are op_type and transfers. After calling dscGetStatus, these elements will contain the interrupt operation status and current number of transfers respectively.

Example of Usage for Checking Interrupt Status

/* run the interrupt operation for 30 seconds, then cancel */ 

#define TIMEOUT_MS 30000 

DSCS dscs; 
DWORD time_last, time_now; 

/* Start interrupt function - dscADSampleInt() etc. */ 

dscGetTime(&time_last); 

do 
{ 
    dscGetTime(&time_now); 
    if (time_now - time_last > TIMEOUT_MS) 
    {
        dscCancelOp(dscb); 
        break; 
    } 
    
    time_last = time_now; 
    dscGetStatus(dscb, &dscs); 
    
} while (dscs.op_type != OP_TYPE_NONE);

Last updated