18 s826_countermodewrite, S826_countermodewrite, S826_countermodewrite) – Sensoray 826 User Manual
Page 48: Counter
chan
Counter channel number in the range 0 to 5.
cfg
Pointer to buffer that will receive the configuration. The format of the returned value is identical to the cfg value used
in the S826_CounterFilterWrite function.
Return Values
If the function succeeds, the return value is zero.
If the function fails, the return value is an error code.
7.3.18 S826_CounterModeWrite
The S826_
Counter
ModeWrite function configures a counter channel's operating mode.
int S826_CounterModeWrite(
uint board, // board identifier
uint chan, // channel number
uint mode // operating mode
);
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.
mode
Channel operating mode (see “Common Applications” for examples):
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10
9
8
7
6
5
4
3
2
1
0
0
IP
IM
0
0
0
TP
NR
UD
BP
OM
OP
TP
TE
TD
K
XS
IP
ExtIn signal polarity. This is ignored if IM=0.
0
Normal polarity.
1
Inverted polarity.
IM
ExtIn mode. If IM>0 then ExtIn is routed to a DIO pin as specified by S826_CounterExtInRoutingWrite.
0
ExtIn input is not used. The counter's ExtIn input will effectively be hardwired to logic '1'.
1
ExtIn input is a count enable permissive.
This is typically used with incremental encoders and event counting, with ExtIn acting as a count enable.
2
ExtIn input is a preload enable permissive.
This is typically used when operating as a pulse generator, with ExtIn used as a pulse trigger.
TP
bit
Preload enables. Determines event(s) that will cause a preload register to be copied to the counter.
Each bit enables preloads for one type of event: ‘1’ = enable, ‘0’ = disable.
24
Preload upon start (when channel switches from halted to running)
16
Preload upon Index active level.
15
Preload upon Index leading edge.
14
Preload upon Index falling edge.
13
Preload upon zero counts reached.
12
Preload when Compare1 matches the counter core.
11
Preload when Compare0 matches the counter core.
826 Instruction Manual
43
Counters