
RM0453 Rev 2
747/1454
RM0453
Advanced-control timer (TIM1)
822
Figure 160. Output stage of capture/compare channel (channel 5, idem ch. 6)
1. Not available externally.
The capture/compare block is made of one preload register and one shadow register. Write
and read always access the preload register.
In capture mode, captures are actually done in the shadow register, which is copied into the
preload register.
In compare mode, the content of the preload register is copied into the shadow register
which is compared to the counter.
25.3.7 Input
capture
mode
In Input capture mode, the Capture/Compare Registers (TIMx_CCRx) are used to latch the
value of the counter after a transition detected by the corresponding ICx signal. When a
capture occurs, the corresponding CCXIF flag (TIMx_SR register) is set and an interrupt or
a DMA request can be sent if they are enabled. If a capture occurs while the CCxIF flag was
already high, then the over-capture flag CCxOF (TIMx_SR register) is set. CCxIF can be
cleared by software by writing it to ‘0’ or by reading the captured data stored in the
TIMx_CCRx register. CCxOF is cleared when written with ‘0’.
The following example shows how to capture the counter value in TIMx_CCR1 when TI1
input rises. To do this, use the following procedure:
1.
Select the proper TI1x source (internal or external) with the TI1SEL[3:0] bits in the
TIMx_TISEL register.
2. Select the active input: TIMx_CCR1 must be linked to the TI1 input, so write the CC1S
bits to 01 in the TIMx_CCMR1 register. As soon as CC1S becomes different from 00,
the channel is configured in input and the TIMx_CCR1 register becomes read-only.
3. Program the appropriate input filter duration in relation with the signal connected to the
timer (when the input is one of the TIx (ICxF bits in the TIMx_CCMRx register). Let’s
imagine that, when toggling, the input signal is not stable during at must 5 internal clock
cycles. We must program a filter duration longer than these 5 clock cycles. We can
validate a transition on TI1 when 8 consecutive samples with the new level have been
MS33101V2
Output
mode
controller
CNT > CCR5
CNT = CCR5
TIM1_CCMR2
OC5M[3:0]
0
1
CC5P
TIM1_CCER
Output
enable
circuit
OC5
CC5E TIM1_CCER
To the master
mode controller
OC5REF
OC5CE
0
1
CC5E
TIM1_CCER
‘0’
TIM1_BDTR
OSSI
MOE
OIS5
TIM1_CR2
(1)
0
1
ocref_clr_int
ETRF
OCREF_CLR
OCCS
TIMx_SMCR