GD32VF103 User Manual
292
0x03 when the counter value matches the content of the TIMERx_CHxCV register.
The PWM mode 0 and PWM mode 1 outputs are also another kind of OxCPRE output which
is setup by setting the CHxCOMCTL field to 0x06/0x07. In these modes, the OxCPRE signal
level is changed according to the counting direction and the relationship between the counter
value and the TIMERx_CHxCV content. With regard to a more detail description refer to the
relative bit definition.
Another special function of the OxCPRE signal is a forced output which can be achieved by
setting the CHxCOMCTL field to 0x04/0x05. Here the output can be forced to an
inactive/active level irrespective of the comparison condition between the counter and the
TIMERx_CHxCV values.
The OxCPRE signal can be forced to 0 when the ETIFP signal is derived from the external
ETI pin and when it is set to a high level by setting the CHxCOMCEN bit to 1 in the
TIMERx_CHCTL0 register. The OxCPRE signal will not return to its active level until the next
update event occurs.
Quadrature decoder
The quadrature decoder function uses two quadrature inputs CI0 and CI1 derived from the
TIMERx_CH0 and TIMERx_CH1 pins respectively to interact with each other to generate the
counter value. Setting SMC=0x01, 0x02, or 0x03 to select that the counting direction of timer
is determined only by the CI0, only by the CI1, or by the CI0 and the CI1. The DIR bit is
modified by hardware automatically during the voltage level change of each direction
selection source. The mechanism of changing the counter direction is shown in.
Counting direction versus encoder signals
. The quadrature decoder can be regarded as
an external clock with a direction selection. This means that the counter counts continuously
from 0 to the counter-reload value. Therefore, users must configure the TIMERx_CAR register
before the counter starts to count.
Table 15-5. Counting direction versus encoder signals
Counting mode
Level
CI0FE0
CI1FE1
Rising
Falling
Rising
Falling
CI0 only
counting
CI1FE1=High
Down
Up
-
-
CI1FE1=Low
Up
Down
-
-
CI1 only
counting
CI0FE0=High
-
-
Up
Down
CI0FE0=Low
-
-
Down
Up
CI0 and CI1
counting
CI1FE1=High
Down
Up
X
X
CI1FE1=Low
Up
Down
X
X
CI0FE0=High
X
X
Up
Down
CI0FE0=Low
X
X
Down
Up
Note:
"-" means "no counting"; "X" means impossible.