General-purpose timers (TIM2/TIM3/TIM4)
Figure 205. Master/slave connection example with 1 channel only timers
Clock
Prescaler
Counter
Compare 1
Note:
The timers with one channel only (see
the OC1 output signal can be used to trigger some other timers (including timers described
in other sections of this document). Check the "TIMx internal trigger connection" table of any
TIMx_SMCR register on the device to identify which timers can be targeted as slave.
The OC1 signal pulse width must be programmed to be at least 2 clock cycles of the
destination timer, to make sure the slave timer will detect the trigger.
For instance, if the destination's timer CK_INT clock is 4 times slower than the source timer,
the OC1 pulse width must be 8 clock cycles.
Using one timer as prescaler for another timer
For example, TIM3 can be configured to act as a prescaler for TIM2. Refer to
do this:
1.
Configure TIM3 in master mode so that it outputs a periodic trigger signal on each
update event UEV. If MMS=010 is written in the TIM3_CR2 register, a rising edge is
output on TRGO each time an update event is generated.
2.
To connect the TRGO output of TIM3 to TIM2, TIM2 must be configured in slave mode
using ITR2 as internal trigger. This is selected through the TS bits in the TIM2_SMCR
register (writing TS=00010).
3.
Then the slave mode controller must be put in external clock mode 1 (write SMS=111 in
the TIM2_SMCR register). This causes TIM2 to be clocked by the rising edge of the
periodic TIM3 trigger signal (which correspond to the TIM3 counter overflow).
4.
Finally both timers must be enabled by setting their respective CEN bits (TIMx_CR1
register).
Note:
If OCx is selected on TIM3 as the trigger output (MMS=1xx), its rising edge is used to clock
the counter of TIM2.
Using one timer to enable another timer
In this example, we control the enable of TIM2 with the output compare 1 of Timer 3. Refer
to
Figure 204
of TIM3 is high. Both counter clock frequencies are divided by 3 by the prescaler compared
to CK_INT (f
664/1390
TIM_mstr
Output
tim_oc1
control
TIM_CH1
for connections. TIM2 counts on the divided internal clock only when OC1REF
= f
/3).
CK_CNT
CK_INT
TS
SMS
Slave
tim_itr
mode
control
Input
trigger
selection
Figure
205) do not feature a master mode. However,
RM0444 Rev 5
TIM_slv
CK_PSC
Prescaler
Figure
RM0444
Counter
MSv65225V1
204. To
Need help?
Do you have a question about the STM32G0 1 Series and is the answer not in the manual?
Questions and answers