Advanced control timer (TIM1)
12.4.15
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. You select One-pulse mode
by setting the OPM bit in the TIM1_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:
In upcounting: CNT < CCRx ≤ ARR (in particular, 0 < CCRx)
In downcounting: CNT > CCRx
Figure 65. Example of one pulse mode.
For example you may want to generate a positive pulse on OC1 with a length of t
after a delay of t
Let's use TI2FP2 as trigger 1:
Map TI2FP2 to TI2 by writing CC2S='01' in the TIM1_CCMR1 register.
TI2FP2 must detect a rising edge, write CC2P='0' in the TIM1_CCER register.
Configure TI2FP2 as trigger for the slave mode controller (TRGI) by writing TS='110' in
the TIM1_SMCR register.
TI2FP2 is used to start the counter by writing SMS to '110' in the TIM1_SMCR register
(trigger mode).
The OPM waveform is defined by writing the compare registers (taking into account the
clock frequency and the counter prescaler).
The t
The t
value (TIM1_ARR - TIM1_CCR1).
Let's say you want to build a waveform with a transition from '0' to '1' when a compare
match occurs and a transition from '1' to '0' when the counter reaches the auto-reload
178/501
TI2
OC1REF
OC1
TIM1_ARR
TIM1_CCR1
0
as soon as a positive edge is detected on the TI2 input pin.
DELAY
is defined by the value written in the TIM1_CCR1 register.
DELAY
is defined by the difference between the auto-reload value and the compare
PULSE
t
DELAY
t
PULSE
RM0008
t
and
PULSE
Need help?
Do you have a question about the STM32F101 Series and is the answer not in the manual?