GD32W51x User Manual
517
Channel output reference signal
As is shown in
Figure 17-43. Output compare logic (x=0,1,2,3)
,
when the TIMERx is used
in the compare match output mode, the OxCPRE signal (Channel x Output prepare signal) is
defined by setting the CHxCOMCTL filed. The OxCPRE signal has several types of output
function. These include, keeping the original level by setting the CHxCOMCTL field to 0x00,
set to 1 by setting the CHxCOMCTL field to 0x01, set to 0 by setting the CHxCOMCTL field
to 0x02 or signal toggle by setting the CHxCOMCTL field to 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 ETIFE 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 17-5. Counting direction versus encoder signals
Counting m ode
Level
CI0FE0
CI1FE1
Rising
Falling
Rising
Falling
CI0 only
counting
CI1FE1=High
Dow n
Up
-
-
CI1FE1=Low
Up
Dow n
-
-
CI1 only
CI0FE0=High
-
-
Up
Dow n