beautypg.com

Sensoray 826 User Manual

Page 38

background image

int S826_CounterSnapshotRead(
uint board, // board identifier
uint chan, // channel number
uint *counts, // pointer to counts buffer
uint *tstamp, // pointer to timestamp buffer
uint *reason, // pointer to reason buffer
uint tmax // maximum time to wait
);

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.

counts

Pointer to a buffer that will receive the latched counts value. Set to NULL to ignore counts.

tstamp

Pointer to a buffer that will receive the timestamp. Set to NULL to ignore timestamp.

reason

Pointer to a buffer that will receive the reason flags, which indicate what caused the snapshot. When a flag bit = '1',
the snapshot was caused by that event type. More than one event may have occurred at the same time, so multiple
bits may be set.

bit

Description

8

Quadrature error

7

Soft snapshot (caused by calling S826_CounterSnapshot)

6

ExtIn rising edge

5

ExtIn falling edge

4

Index rising edge

3

Index falling edge

2

Zero counts reached

1

Compare1 match

0

Compare0 match

Set to NULL to ignore the reason.

tmax

Maximum time, in microseconds, to wait for data. See Event-Driven Applications for details.

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 reads a previously acquired snapshot from the snapshot FIFO, consisting of the counts at a particular
moment in time and the associated timestamp and reason flags. Each snapshot can be read only one time; when a
snapshot is read, it is removed from the FIFO and cannot be read again.

Snapshots may be acquired in response to asynchronous events. In such cases, snapshots may occur at any time.
However, if snapshots are not automatically acquired, or for some other reason it is necessary to invoke a snapshot
under program control, the application program must call S826_CounterSnapshot to capture a new snapshot before
calling this function to read the snapshot.

The reason flags indicate the type of event that caused the snapshot. If two or more simultaneous events would each
cause a snapshot, all of the associated reason flags will be set.

826 Instruction Manual

33

Counters