English
Language : 

EFM32WG Datasheet, PDF (604/834 Pages) List of Unclassifed Manufacturers – The EFM32WG Wonder Gecko is the ideal choice for demanding 8-, 16-, and 32-bit energy sensitive applications.
...the world's most energy friendly microcontrollers
The direction of the quadrature code and control of the counter is generated by the simple binary function
outlined by Table 24.1 (p. 604) . Note that this function also filters some invalid inputs that may occur
when the shaft changes direction or temporarily toggles direction.
Table 24.1. PCNT QUAD Mode Counter Control Function
Inputs
S1IN posedge
0
0
1
1
S1IN negedge
0
1
0
1
Control/Status
Count Enable
0
1
1
0
CNTDIR status bit
0
0
1
0
Note
PCNTn_S1IN is sampled on both edges of PCNTn_S0IN.
24.3.2 Hysteresis
By default the pulse counter wraps to 0 when passing the configured top value, and wraps to the top
value when counting down from 0. On these events, a system will likely want to wake up to store and
track the overflow count. This is fine if the pulse counter is tracking a monotonic value or a value that
does not change directions frequently. If you have the latter however, and the counter changes directions
around the overflow/underflow point, the system will have to wake up a lot to keep track of the rotations,
causing high current consumptions
To solve this, the pulse counter has a way of introducing hysteresis to the counter. When HYST in
PCNTn_CTRL is set, the pulse counter will always wrap to TOP/2 on underflows and overflows. This
takes the counter away from the area where it might overflow or underflow, removing the problem.
Given a starting value of 0 for the counter, the absolute count value when hysteresis is enabled can
be calculated with the equations Equation 24.1 (p. 604) or Equation 24.2 (p. 604) , depending on
whether the TOP value is even or odd.
Absolute position with hysteresis and even TOP value
CNTabs = CNT - UFCNT x (TOP/2+1) + OFCNT x (TOP/2+1)
(24.1)
Absolute position with hysteresis and odd TOP value
CNTabs = CNT - UFCNT x (TOP/2+1) + OFCNT x (TOP/2+2)
(24.2)
24.3.3 Auxiliary counter
To be able to keep explicit track of counting in one direction in addition to the regular counter which
counts both up and down, the auxiliary counter can be used. The pulse counter can for instance be
configured to keep track of the absolute rotation of the wheel, and at the same time the auxiliary counter
can keep track of how much the wheel has reversed.
The auxiliary counter is enabled by configuring AUXCNTEV in PCNTn_CTRL. It will always count up,
but it can be configured whether it should count up on up-events, down-events or both, keeping track
of rotation either way or general movement. The value of the auxiliary counter can be read from the
PCNTn_AUXCNT register.
Overflows on the auxiliary counter happen when the auxiliary counter passes the top value of the pulse
counter, configured in PCNTn_TOP. In that event, the AUXOF interrupt flag is set, and the auxiliary
counter wraps to 0.
2013-05-08 - Wonder Gecko Family - d0233_Rev0.50
604
www.energymicro.com