Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
194
/
631
Figure 10-31 6-step PWM generation, COM example (OSSR=1)
Encoder interface mode
The encoder uses two inputs TI1 and TI2 as an interface and the counter counts on every edge change on TI1FP1 or
TI2FP2. The counting direction is automatically controlled by hardware TIMx_CTRL1.DIR. There are three types
of encoder counting modes:
1. The counter only counts on the edge of TI1, TIMx_SMCTRL.SMSEL = ‘001’;
2. The counter only counts on the edge of TI2, TIMx_SMCTRL.SMSEL =’010’;
3. The counter counts on the edges of TI1 and TI2 at the same time, TIMx_SMCTRL.SMSEL = ‘011’;
The encoder interface is equivalent to using an external clock with direction selection, and the counter only counts
continuously between 0 and the auto-reload value (TIMx_AR.AR [15:0]). Therefore, it is necessary to configure the
auto-reload register TIMx_AR in advance.
Note: Encoder mode and external clock mode 2 are not compatible and must not be selected together.
The relationship between the counting direction and the encoder signal is shown in
Table 10-1 Counting direction versus
(CCRx)
Counter (CNT)
COM event
CCxEN=1
CCxNEN=0
OCxMD=100(forced inactive)
OCxREF
OCx
OCxN
write COM=1
write OCxMD=100
CCxEN=1
CCxNEN=0
OCxMD=100
CCxEN=1
CCxNEN=0
OCxMD=100(forced inactive)
CCxEN=0
CCxNEN=1
OCxMD=101
Ocx
OCxN
OCx
OCxN
CCxEN=1
CCxNEN=0
OCxMD=100(forced inactive)
CCxEN=1
CCxNEN=0
OCxMD=100
write CCxNEN=1
和
OCxMD=101
write CCxNEN=0
和
OCxMD=100