
EM358x
190
Rev. 0.4
Configure Timer 2 in gated mode: Write TIM_SMS = 101 in the TIM2_SMCR register.
Reset Timer 1: Write 1 in the TIM_UG bit (TIM1_EGR register.
Reset Timer 2 by writing 1 in the TIM_UG bit (TIM2_EGR register).
Initialize Timer 2 to 0xE7: Write 0xE7 in the Timer 2 counter (TIM2_CNTL).
Enable Timer 2: Write 1 in the TIM_CEN bit in the TIM2_CR1 register.
Start Timer 1: Write 1 in the TIM_CEN bit in the TIM1_CR1 register.
Stop Timer 1: Write 0 in the TIM_CEN bit in the TIM1_CR1 register.
Figure 10-33. Gating Timer 2 with Enable of Timer 1
10.3.15.3 Using One Timer to Start the Other Timer
In this example (see Figure 10-34), the enable of Timer 2 is set with the UEV of Timer 1. Timer 2 starts counting
from its current value (which can be non-zero) on the divided internal clock as soon as Timer 1 generates the
UEV.
When Timer 2 receives the trigger signal its TIM_CEN bit is automatically set and the counter counts until 0 is
written to the TIM_CEN bit in the TIM2_CR1 register. Both counter clock frequencies are divided by 3 by the
prescaler compared to CK_INT (f
CK_CNT
= f
CK_INT
/3).
Configure Timer 1 in master mode to send its UEV as trigger output: WriteTIM_MMS = 010 in the TIM1_CR2
register.
Configure the Timer 1 period (TIM1_ARR register).
Configure Timer 2 to get the input trigger from Timer 1: Write TIM_TS = 000 in the TIM2_SMCR register.
Configure Timer 2 in trigger mode. Write TIM_SMS = 110 in the TIM2_SMCR register.
Start Timer 1: Write 1 in the TIM_CEN bit in theTIM1_CR1 register.
Содержание EMBER EM358 series
Страница 2: ...EM358x 2 Rev 0 4 ...
Страница 7: ...EM358x Rev 0 4 7 ...