You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
General-purpose timers<br />
<strong>STM32W108C8</strong><br />
cleared by software writing a 1 to its bit or reading the captured data stored in the<br />
TIMx_CCRy register. To clear the INT_TIMMISSCCyIF bit, write a 1 to it.<br />
Note:<br />
The following example shows how to capture the counter value in the TIMx_CCR1 when the<br />
TI1 input rises.<br />
● Select the active input: TIMx_CCR1 must be linked to the TI1 input, so write the<br />
TIM_CC1S bits to 01 in the TIMx_CCMR1 register. As soon as TIM_CC1S becomes<br />
different from 00, the channel is configured in input and the TIMx_CCR1 register<br />
becomes read-only.<br />
● Program the required input filter duration with respect to the signal connected to the<br />
timer, when the input is one of the TIy (ICyF bits in the TIMx_CCMR1 register).<br />
Consider a situation in which, when toggling, the input signal is unstable during at most<br />
5 internal clock cycles. The filter duration must be longer than these 5 clock cycles. The<br />
transition on TI1 can be validated when 8 consecutive samples with the new level have<br />
been detected (sampled at PCLK frequency). To do this, write the TIM_IC1F bits to<br />
0011 in the TIMx_CCMR1 register.<br />
● Select the edge of the active transition on the TI1 channel by writing the TIM_CC1P bit<br />
to 0 in the TIMx_CCER register (rising edge in this case).<br />
● Program the input prescaler: In this example, the capture is to be performed at each<br />
valid transition, so the prescaler is disabled (write the TIM_IC1PS bits to 00 in the<br />
TIMx_CCMR1 register).<br />
● Enable capture from the counter into the capture register by setting the TIM_CC1E bit<br />
in the TIMx_CCER register.<br />
● If needed, enable the related interrupt request by setting the INT_TIMCC1IF bit in the<br />
INT_TIMxCFG register.<br />
● When an input capture occurs:<br />
– The TIMx_CCR1 register gets the value of the counter on the active transition.<br />
– INT_TIMCC1IF flag is set (capture/compare interrupt flag). The missed<br />
capture/compare flag INT_TIMMISSCC1IF in INT_TIMxMISS is also set if another<br />
capture occurs before the INT_TIMCC1IF flag is cleared.<br />
– An interrupt may be generated if enabled by the INT_TIMCC1IF bit.<br />
To detect missed captures reliably, read captured data in TIMxCCRy before checking the<br />
missed capture/compare flag. This sequence avoids missing a capture that could happen<br />
after reading the flag and before reading the data.<br />
Software can generate IC interrupt requests by setting the corresponding TIM_CCyG bit in<br />
the TIMx_EGR register.<br />
10.1.6 PWM input mode<br />
This mode is a particular case of input capture mode. The procedure is the same except:<br />
●<br />
●<br />
●<br />
Two ICy signals are mapped on the same TIy input.<br />
These two ICy signals are active on edges with opposite polarity.<br />
One of the two TIyFP signals is selected as trigger input and the slave mode controller<br />
is configured in reset mode.<br />
123/215 Doc ID 018587 Rev 2