BL4S200 User’s Manual
75
setCapture
int setCapture(int channel, int mode, int edge, word options);
FUNCTION DESCRIPTION
Sets up the channel as an event capture input, with selectable modes and edge settings.
The counter will run from a gated main or prescaled clock signal based on the run cri-
teria of the selected mode, and begin/end events can be set to capture the count at the
time of these events. Optionally, a second channel can be set (which shares the same
RIO channel input block as
channel
) for two-signal begin/end event detection. Use
getBegin()
and
getEnd()
to read the captured count values and use
reset-
Counter()
to force a reset of the counter.
PARAMETERS
channel
channel to use for the begin event input for all modes except
BL_
CNT_TIL_END
, then it specifies the end event input.
mode
mode macro for the counter/timer:
BL_CNT_RUN
— continuous count mode
BL_CNT_BEGIN_END
— start count on begin event, continue to
count until end event detected
BL_CNT_TIL_END
— count until end event detected
BL_CNT_ON_BEGIN
— count while begin signal is active
NOTE:
If an end event occurs before the begin event, the count will begin then end
immediately on the begin event, and the end count will be 1. The begin count will be 0
or 1 based on the edge that triggered the event (0 = rising, 1 = falling).
edge
edge/state macro setting for the begin event for all modes except
BL_CNT_TIL_END
, then it specifies the end event:
BL_EVENT_RISE
— begin event on rising edge
BL_EVENT_FALL
— begin event on falling edge
BL_EVENT_BOTH
— begin event on any edge
The following two settings are only for the
ON_BEGIN
mode:
BL_BEGIN_HIGH
— begin active while signal is high
BL_BEGIN_LOW
— begin active while signal is low