Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>STM32W108C8</strong><br />
General-purpose timers<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Reset Timer 2 by writing 1 in the TIM_UG bit (TIM2_EGR register).<br />
Initialize Timer 2 to 0xE7 by writing 0xE7 in the Timer 2 counter (TIM2_CNTL).<br />
Enable Timer 2 by writing 1 in the TIM_CEN bit (TIM2_CR1 register).<br />
Start Timer 1 by writing 1 in the TIM_CEN bit (TIM1_CR1 register).<br />
Stop Timer 1 by writing 0 in the TIM_CEN bit (TIM1_CR1 register).<br />
Figure 45. Gating Timer 2 with enable of Timer 1<br />
Using one timer to start the other timer<br />
In this example, the enable of Timer 2 is set with the update event of Timer 1. Refer to<br />
Figure 43 for connections. Timer 2 starts counting from its current value (which can be nonzero)<br />
on the divided internal clock as soon as Timer 1 generates the update event.<br />
When Timer 2 receives the trigger signal its TIM_CEN bit is automatically set and the<br />
counter counts until 0 is written to the TIM_CEN bit in the TIM2_CR1 register. Both counter<br />
clock frequencies are divided by 3 by the prescaler compared to CK_INT (fCK_CNT =<br />
fCK_INT/3).<br />
● Configure Timer 1 in master mode to send its update event as trigger output<br />
(TIM_MMS = 010 in the TIM1_CR2 register).<br />
● Configure the Timer 1 period (TIM1_ARR register).<br />
● Configure Timer 2 to get the input trigger from Timer 1 (TIM_TS = 000 in the<br />
TIM2_SMCR register).<br />
● Configure Timer 2 in trigger mode (TIM_SMS = 110 in the TIM2_SMCR register).<br />
● Start Timer 1: Write 1 in the TIM_CEN bit (TIM1_CR1 register).<br />
Doc ID 018587 Rev 2 138/215