BL4S200 User’s Manual
73
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
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 pin event
edge settings (these settings cannot be on be same pin as the up
count). The low 5 bits are the channel number for the down count
input
If the stop on match mode is selected,
options
has the match
count to stop at (other match registers on the block are set to max.).
electronic components distributor