296
/
838
Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
Slave mode: Trigger mode
In trigger mode, the trigger event (rising edge/falling edge) of the input port can trigger the counter to start counting.
The following is an example of a trigger pattern:
1. Channel 2 is configured as input to detect the rising edge of TI2 (TIMx_CCMOD1.CC2SEL=01,
TIMx_CCEN.CC2P=0);
2. Select from mode to trigger mode (TIMx_SMCTRL.SMSEL=110), select TI2 for trigger input
(TIMx_SMCTRL.TSEL=110);
When TI2 detects a rising edge, the counter starts counting, and the trigger flag is set (TIMx_STS.TITF=1);
The delay between the rising edge on TI2 and the actual start of the counter is due to the resynchronization circuit on
TI2 input.
Figure 11-28 Control circuit in Trigger mode
Slave mode: Gated mode
In gate control mode, the level polarity of the input port can control whether the counter counts.
The following is an example of a gated pattern:
1. Channel 1 is configured as input detection active low on TI1 (TIMx_CCMOD1.CC1SEL=01,
TIMx_CCEN.CC1P=1);
2. Select the slave mode as the gated mode (TIMx_SMCTRL.SMSEL=101), and select TI1 as the trigger input
(TIMx_SMCTRL.TSEL=101);
3. Start counter (TIMx_CTRL1.CNTEN = 1)
When TI1 detects that the level changes from low to high, the counter stops counting, and when TI1 detects that the
level changes from high to low, the counter starts counting, and the trigger flag will be set when it starts or stops
counting (TIMx_STS.TITF=1);
The delay between the rising edge on TI1 and the actual stop of the counter is due to the resynchronization circuit on
TI2
Counter register
64
66 67 68
65
CNTEN
TITF
Counter clock=CN_CNT=CK_PSC