beautypg.com

10 s826_counterstatewrite, S826_counterstatewrite – Sensoray 826 User Manual

Page 43

background image

Return Values

If the function succeeds, the return value is zero.

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

Remarks

If sticky is false, the level will be ignored. In this case, the channel's software preload command will be strobed active
and then immediately return to its inactive state, thus causing Preload0 to be copied to the counter core.

If sticky is true, the specified level will be continuously applied to the channel's software preload command until
changed by a subsequent call to this function. Typically, sticky will only be asserted if the counter is operating as a
Pulse Generator, and only when output retriggering is enabled. When sticky and level are both '1', the counter will
continuously preload from Preload0, thus causing the pulse output to go active and remain active until the function is
called again to set the level to '0'; at that time, the counter will be allowed to resume counting.

7.3.10 S826_CounterStateWrite

The S826_CounterStateWrite function starts or stops channel operation.

int S826_CounterStateWrite(
uint board, // board identifier
uint chan, // channel number
uint state // channel state
);

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.

state

Channel state: 0 = halted, 1 = running.

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 is used to start and stop counter channel operation, thus placing the channel in either the “running” or
“halted” state. A channel's operating mode should be configured before switching it to the running state; this is done by
calling S826_CounterModeWrite. A channel will operate as specified by the mode register while it is in the running
state.

In the halted state:

Counting and preloading are not allowed.

Counter core is reset to zero counts.

Snapshot register is marked empty.

Output is held inactive.

Quadrature error is reset.

826 Instruction Manual

38

Counters