BL4S100 User’s Manual
53
setCounter
int setCounter(int channel, int mode, int edge, word options);
FUNCTION DESCRIPTION
Sets up the channel as a counter input, with selectable modes and edge settings. The
counter will increment or decrement on each selected edge event. Use
getCounter()
to read the current count and use
resetCounter()
to force a reset of the counter.
PARAMETERS
channel
channel to use for the up count input, 0–11 (pins IN0–IN11)
mode
macro to set the mode of the counter:
BL_UP_COUNT
— continuous up count mode
BL_DOWN_COUNT
— up/down count mode (uses 2 pins)
BL_MATCH_ENABLE
— continuous up count mode with count
stopping on any match event
edge
edge setting macro for the up count event:
BL_EDGE_RISE
— up count on rising edge
BL_EDGE_FALL
— up count on falling edge
BL_EDGE_BOTH
— up count on either edge
options
options based on mode (N/A if the continuous up mode is selected):
BL_EDGE_RISE
— down count on rising edge
BL_EDGE_FALL
— down count on falling edge
BL_EDGE_BOTH
— down count on either edge
If the up/down mode is selected,
options
has down count channel
and event edge settings (these settings cannot be on the same pin
as the up count) ORed together. The low 4 bits are the channel num-
ber for the down count input
If the
BL_MATCH_ENABLE
mode is selected,
options
has the
match count to stop at (other match registers on the block are set
to max.).