Nations Technologies Inc.
Tel
:
+86-755-86309900
:
info@nationstech.com
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
177
/
631
corresponding interrupt enable is pulled high.
The TIMx_STS. CCxITF bit is set by hardware when a capture event occurs and is cleared by software or by reading
the TIMx_CCDATx register.
The overcapture flag TIMx_STS.CCxOCF is set equal to 1 when the counter value is captured in the TIMx_CCDATx
register and TIMx_STS.CC1ITF is already pulled high. Unlike the former, TIMx_STS.CCxOCF is cleared by writing
0 to it.
To achieve a rising edge of the TI1 input to capture the counter value into the TIMx_CCDAT1 register, the
configuration flow is as follows:
To select a valid input:
Configure TIMx_CCMOD1.CC1SEL to ‘01’. At this time, the input is the CC1 channel, and IC1 is mapped to
TI1.
Program the desired input filter duration:
Define the sampling frequency of the TI1 input and the length of the digital filter by configuring the
TIMx_CCMODx.ICxF bits. Example: If the input signal jitters up to 5 internal clock cycles, we must choose a
filter duration longer than these 5 clock cycles. When 8 consecutive samples (sampled at f
DTS
frequency) with
the new level are detected, we can validate the transition on TI1. Then configure TIMx_CCMOD1. IC1F to
‘0011’.
By configuring TIMx_CCEN .CC1P=0, select the rising edge as the valid transition polarity on the TI1 channel.
Configure the input prescaler. In this example, configure TIMx_CCMOD1.IC1PSC= ‘00’ to disable the
prescaler because we want to capture every valid transition.
Enable capture by configuring TIMx_CCEN. CC1EN = ‘1’.
If you want to enable DMA request, you can configure TIMx_DINTEN.CC1DEN=1.If you want enable related
interrupt request, you can configureTIMx_DINTEN.CC1IEN bit=1
PWM input mode
There are some differences between PWM input mode and normal input capture mode, including:
Two ICx signals are mapped to the same TIx input.
The two ICx signals are active on edges of opposite polarity.
Select one of two TIxFP signals as trigger input.
The slave mode controller is configured in reset mode.
For example, the following configuration flow can be used to know the period and duty cycle of the PWM signal on
TI1 (It depends on the frequency of CK_INT and the value of the prescaler).
Configure TIMx_CCMOD1.CC1SEL equal to ‘01’ to select TI1 as valid input for TIMx_CCDAT1.
Configure TIMx_CCEN.CC1P equal to ‘0’ to select the active polarity of filtered timer input 1(TI1FP1), valid
on the rising edge.