2 s826_counterwaitcancel, 3 s826_countercomparewrite, S826_counterwaitcancel – Sensoray 826 User Manual
Page 39: S826_countercomparewrite
Quadrature-encoded clocks are monitored for encoding errors as described in Quadrature Decoder. When an encoding
error is detected, a snapshot is captured (with reason bit 8 set) and an internal error flag is set. While the error flag
remains set, subsequent encoding errors will be ignored and will not trigger new snapshots (though other types of
triggers will continue to cause snapshots). The error flag is automatically cleared when this function reads the error-
triggered snapshot, or when the channel is halted, or when the snapshot FIFO becomes empty. The latter case ensures
that the error flag will be cleared if the error-triggered snapshot is lost due to FIFO overflow.
This function can operate in either blocking or non-blocking mode, depending on the value of tmax. If tmax is zero, the
function will return immediately. If tmax is greater than zero, the calling thread will block until a snapshot is available
or tmax elapses. The function will return either S826_ERR_OK or S826_ERR_FIFOOVERFLOW if a snapshot was
read, or S826_ERR_NOTREADY if no snapshot is available. S826_ERR_ FIFOOVERFLOW indicates that a snapshot
was successfully read, but the channel's snapshot FIFO overflowed (one or more snapshots were lost); the FIFO
overflow status will be automatically cleared when the function returns.
When this function is blocking, it will immediately return S826_ERR_CANCELLED if S826_CounterWaitCancel is
called by another thread, or S826_ERR_BOARDCLOSED if S826_SystemClose is called. In either case, the counts,
tstamp and reason values will be invalid.
7.3.2 S826_CounterWaitCancel
The S826_CounterWaitCancel function cancels a blocking wait on a counter channel.
int S826_CounterWaitCancel(
uint board, // board identifier
uint chan // channel number
);
Parameters
board
826 board number. This must match the settings of the board's dip switches as described in section 2.2.
chan
Counter channel number in the range 0 to 5, for which waiting is to be canceled.
Return Values
If the function succeeds, the return value is zero.
If the function fails, the return value is an error code.
Remarks
This function cancels blocking on a counter channel so that another thread, which is blocked by
S826_CounterSnapshotRead while waiting for a snapshot, will return immediately with S826_ERR_CANCELLED.
7.3.3 S826_CounterCompareWrite
The S826_CounterCompareWrite function writes to a compare register.
int S826_CounterCompareWrite(
uint board, // board identifier
uint chan, // channel number
uint regid, // register identifier
uint counts // counts value
);
Parameters
board
826 board number. This must match the settings of the board's dip switches as described in section 2.2.
826 Instruction Manual
34
Counters