Monarco-HAT-Hardware-Reference-Manual

Monarco HAT Hardware Reference Manual 20190728-1
14
COUNTER Technology Function
There are two COUNTER hardware function modules available:
COUNTER1 Input channels: A = DIN1, B = DIN2,
COUNTER2 Input channels: A = DIN3, B = DIN4, C = DIN2 (shared with COUNTER1).
Each COUNTER module contains 16bit hardware counter which can count up or down. Counter value
wrap-around on overflow.
Several function modes are available for each COUNTER module:
MODE = 0: disabled,
MODE = 1: pulse counting on input channel A,
MODE = 2: quadrature encoder on input channels A + B.
In mode 1, additional configuration is available count direction:
DIR = 0: up-counting,
* DIR = 1: direction given by channel B input, low = up-counting, high = down-counting,
and input channel A active edge:
EDGE = 0: count on rising edge,
EDGE = 1: count on falling edge,
EDGE = 2: count on both (rising and falling) edges.
COUNTER2 provides additional Counter Capture function which allows you to store instantaneous
counter value in auxiliary data register when active edge on input channel C occurred:
* CAPTURE = 0: capture function disabled,
* CAPTURE = 1: capture on rising edge,
* CAPTURE = 2: capture on falling edge,
* CAPTURE = 3: capture on both (rising and falling) edges.
Note: COUNTER2 module cannot be activated simultaneously with PWM2 module.