Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
301
/
631
Since the signal injected on the LPTIM external Input1 is also used to clock the LPTIM kernel logic, there
is some initial latency (after the LPTIM is enabled) before the counter is incremented. More precisely, the
first five active edges on the LPTIM external Input1 (after LPTIM is enable) are lost.
Encoder mode
The Encoder mode can handle signals from quadrature encoders which used to detect angular position of rotary
elements. The encoder mode allows the counter counts the events within 0 and LPTIM_ARR.ARRVAL[15:0] value.
(0 up to LPTIM_ARR.ARRVAL[15:0] or LPTIM_ARR.ARRVAL[15:0] to 0). In this case, user must configure
LPTIM_ARR.ARRVAL[15:0] before enable the counter. From external Input1 and Input2, a clock is generated for
the counter. The counting direction depends on the phase between these two input signals.
The Encoder mode is only available when the LPTIM use an internal clock source to clock. The signals frequency
on both Input1 and Input2 inputs must not exceed the LPTIM internal clock frequency divided by 4. This is mandatory
in order to guarantee a proper operation of the LPTIM.
The change of counting direction is updated by the two Down and Up flags in the LPTIM_INTSTS register. Also, an
interrupt can be generated for both direction change events if enabled through the LPTIM_INTEN register.
User can enable Encoder mode by setting LPTIM_CFG.ENC bit. And the LPTIM need to be configured in continuous
mode first.
When Encoder mode is active, the LPTIM counter is modified automatically following the speed and the direction
of the incremental encoder. Therefore, its content always represents the encoder’s position. The count direction,
signaled by the Up and Down flags, correspond to the rotation direction of the encoder rotor.
According to the edge polarity configured using the LPTIM_CFG.CLKPOL[1:0] bits, different counting scenarios
are possible. The following table summarizes the possible combinations, assuming that Input1 and Input2 do not
switch at the same time.
Table 13-3 Encoder counting scenarios
Trigger edge
The signal is opposite (Input1
For Input2, Input2
For Input1)
Input1 signal
Input2 signal
Rising
Falling
Rising
Falling
Rising Edge
High
Down
No count
Up
No count
Low
Up
No count
Down
No count
Falling Edge
High
No count
Up
No count
Down
Low
No count
Down
No count
Up
Both Edges
High
Down
Up
Up
Down
Low
Up
Down
Down
Up
The following figure shows a counting sequence for Encoder mode where both-edge polarity is configured.
Caution:
In this mode the LPTIM must be clocked by an internal clock source, so the LPTIM_CFG.CLKSEL bit must