16-bit advanced control timer (TIM1) RM0016
174/449 Doc ID 14587 Rev 8
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 clock/trigger controller. Generating the
waveform can be done in output compare mode or PWM mode. Select one-pulse mode by
setting the OPM bit in the TIM1_CR1 register. This makes the counter stop automatically at
the next 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:
● In up-counting: CNT< CCRi ≤ ARR (in particular, 0 < CCRi),
● In down-counting: CNT> CCRi
Figure 72. Example of one-pulse mode
Example
This example shows how to generate a positive pulse on OC1 with a length of t
PULSE
and
after a delay of t
DELAY
as soon as a positive edge is detected on the TI2 input pin.
Follow the procedure below to use IC2 as trigger 1:
● Map IC2 on TI2 by writing CC2S = 01 in the TIM1_CCMR2 register
● IC2 must detect a rising edge, so write CC2P = 0 in the TIM1_CCER1 register
● Configure IC2 as trigger for the clock/trigger controller (TRGI) by writing TS = 110 in the
TIM1_SMCR register.
● IC2 is used to start the counter by writing SMS to 110 in the TIM1_SMCR register
(trigger mode).
TI2
COUNTER
t
0
TIMx_ARR
TIMx_CCR1
OC1
t
DELAY
t
PULSE
OC1REF