General-purpose timers (TIM15/TIM16/TIM17) RM0440
1382/2126 RM0440 Rev 4
30.4.18 One-pulse mode
One-pulse mode (OPM) is a particular case of the previous modes. It allows the counter to
be started in response to a stimulus and to generate a pulse with a programmable length
after a programmable delay.
Starting the counter can be controlled through the slave mode controller. Generating the
waveform can be done in output compare mode or PWM mode. One-pulse mode is selected
by setting the OPM bit in the TIMx_CR1 register. This makes the counter stop automatically
at the next update event UEV.
A pulse can be correctly generated only if the compare value is different from the counter
initial value. Before starting (when the timer is waiting for the trigger), the configuration must
be:
• CNT < CCRx ≤ ARR (in particular, 0 < CCRx)
Figure 473. Example of one pulse mode.
For example one may want to generate a positive pulse on tim_oc1 with a length of t
PULSE
and after a delay of t
DELAY
as soon as a positive edge is detected on the tim_ti2 input pin.
Let’s use tim_ti2fp2 as trigger 1:
1. Select the proper tim_ti2_in[1..15] source (internal or external) with the TI2SEL[3:0] bits
in the TIMx_TISEL register.
2. Map tim_ti2fp2 to tim_ti2 by writing CC2S=’01’ in the TIMx_CCMR1 register.
3. tim_ti2fp2 must detect a rising edge, write CC2P=’0’ and CC2NP=’0’ in the
TIMx_CCER register.
4. Configure tim_ti2fp2 as trigger for the slave mode controller (tim_trgi) by writing
TS=’00110’ in the TIMx_SMCR register.
5. tim_ti2fp2 is used to start the counter by writing SMS to ‘110’ in the TIMx_SMCR
register (trigger mode).
MSv62344V1
tim_ti2
tim_oc1ref
Counter
t
0
TIM1_ARR
TIM1_CCR1
tim_oc1
t
DELAY
t
PULSE