Generation Of Single Pulse - WCH CH32V003 Series Reference Manual

Table of Contents

Advertisement

CH32V003 Reference Manual
1)
Set TI2 to trigger. Setting the CC2S field to 01b to map TI2FP2 to TI2; setting the CC2P bit to 0b to set
TI2FP2 as rising edge detection; setting the TS field to 110b to set TI2FP2 as trigger source; setting the
SMS field to 110b to set TI2FP2 to be used to start the counter.
2)
Tdelay is determined by the value of the Compare Capture Register, and Tpulse is determined by the
value of the Auto Reload Value Register and the Compare Capture Register.
10.3.9 Encoder mode
The encoder mode is a typical application of the timer and can be used to access the biphasic output of the
encoder. The counting direction of the core counter is synchronized with the direction of the encoder's rotation
axis, and each pulse output from the encoder will cause the core counter to add or subtract one. To use the
encoder, set the SMS field to 001b (count only on TI2 edge), 010b (count only on TI1 edge) or 011b (count on
both TI1 and TI2 edges), connect the encoder to the input of comparison capture channels 1 and 2, and set a
value for the reload value register, which can be set to a larger value. When in encoder mode, the internal
compare capture register, prescaler, repeat count register, etc. of the timer are working normally. The following
table shows the relationship between the counting direction and the encoder signal.
Table 10-1 Relationship between counting direction and encoder signal of timer encoder mode
Counting effective edges
Counting at TI1 edge only
Counting at TI2 edge only
Double edge counting at
TI1 and TI2
V1.3
Figure 10-5 Generation of single pulse
The level
TI1FP1 signal edge
of
Rising
relative
edge
signals
Downward
high
counting
Upward
low
counting
high
No count
low
Downward
high
counting
Upward
low
counting
94
TI2FP2 signal
Falling
Rising
edge
edge
Upward
counting
No count
Downward
counting
Upward
counting
Downward
counting
Upward
向上计数
counting
Downward
Downward
counting
counting
http://wch.cn
Falling
edge
Downward
counting
Upward
counting
Downward
counting
Upward
counting

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents

Save PDF