14.3.4 Triggered compare and clear
The pulse counter features triggered compare and clear. When enabled, a configurable trigger will induce a comparison between the
main counter, PCNTn_CNT, and the top value, PCNTn_TOP. After the comparison, the counter is cleared. The trigger for a compare
and clear event is configured in the TCCMODE bit-field in PCNTn_CTRL. There are two options, LFA and PRS. If LFA is selected, the
pulse counter will be compared with the top value, and cleared every 2
N
LFA clock cycle (where N is the value of TCCPRESC in
PCNTn_CTRL). If a PRS trigger is selected, the active PRS channel is configured in TCCPRSSEL in PCNTn_CTRL. The PRS input
can be inverted by setting TCCPRSPOL, triggering the compare and clear on the negative edge of the PRS input. The PRS input can
also be used as a gate for the pulse counter clock. This is enabled by setting PRSGATEEN in PCNTn_CTRL.
Note:
When PRSGATEEN is set, the clock to the entire pulse counter will be gated by the PRS input, meaning that register writes will not take
effect while the gated clock is inactive.
Comparison with PCNTn_TOP can be performed in three ways: range, greater than or equal, and less than or equal. TCCCOMP in
PCNTn_CTRL configures comparison mode. Upon a compare match, the TCC interrupt is set, and the PRS output from the pulse
counter is set. The PRS output will remain set until the next compare and clear event. Triggered compare and clear is intended for use
when the pulse counter is configured to count up. In this mode, PCNTn_CNT will not wrap to 0 when hitting PCNTn_TOP, it will keep
counting. In addition, the counter will not overflow, it will rather stop counting, just setting the overflow interrupt flag.
Figure 14.11 PCNT Triggered compare and clear on page 371
shows an overview of the control circuitry for triggered compare and
clear. The control circuitry includes two positive edge detectors (PED) and glitch filters, used to generate clocks for the pulse counter.
The two clock outputs are mutually exclusive: If both edge detectors receive a pulse at the same time, the output pulse from one of
them will be postponed until the other edge detectors output pulse has completed.
CNT
TCCPRSPOL
PRS in
PRSGATEEN
PCNTnCLK
PED and gltich
filter
CLK
PCNT
TCCMODE
LFACLK
Compare match
clear
TCCCOMP
<=TOP
LTOE
GTOE
RANGE
>=TOP
>=TOP[7:0]
&&
<= TOP[15:8]
PRS
LFA
TCC PRS out
TCC interrupt
Prescaler
TCCPRESC
Triggered compare and clear control
TCCMODE
DISABLED
LFA or PRS
PED and gltich
filter
Figure 14.11. PCNT Triggered compare and clear
Note:
TCCMODE, TCCPRESC, PRSGATEEN, TCCPRSPOL, and TCCPRSSEL in PCNTn_CTRL should only be altered when RSTEN in
PCNTn_CTRL is set.
EFM32JG1 Reference Manual
PCNT - Pulse Counter
silabs.com
| Smart. Connected. Energy-friendly.
Preliminary Rev. 0.6 | 371