beautypg.com

6 s826_counterread, 7 s826_counterpreloadwrite, S826_counterread – Sensoray 826 User Manual

Page 41: S826_counterpreloadwrite

background image

If the function fails, the return value is an error code.

Remarks

This function forces a snapshot to be captured immediately. It is typically used to capture a snapshot under program
control prior to reading a counter. This is one of two methods of reading the core's instantaneous counts; the other
method is S826_CounterRead. This function may be called at any time when the counter channel is running.

7.3.6 S826_CounterRead

The S826_CounterRead function reads the counter core's instantaneous counts.

int S826_CounterRead(
uint board, // board identifier
uint chan, // channel number
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.

chan

Counter channel number in the range 0 to 5.

counts

Pointer to a buffer that will receive the instantaneous counts from the counter core.

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 directly reads and returns the value currently stored in the counter core. If a timestamp is also needed, the
application can call this function and also call S826_TimestampRead, or it may trigger a soft snapshot and then read the
snapshot.

7.3.7 S826_CounterPreloadWrite

The S826_CounterPreloadWrite function writes to a preload register.

int S826_CounterPreloadWrite(
uint board, // board identifier
uint chan, // channel number
uint reg, // 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.

chan

Counter channel number in the range 0 to 5.

reg

Selects the preload register to write to: 0 = Preload0 register, 1 = Preload1 register.

counts

The 32-bit value to be written to the selected Preload register.

826 Instruction Manual

36

Counters