
EM358x
188
Rev. 0.4
In the following example, shown in Figure 10-30, the up-counter is incremented at each rising edge of the ETR
signal as soon as a rising edge of TI1 occurs:
Configure the external trigger input circuit: Program the TIMx_SMCR register as follows:
TIM_ETF = 0000: no filter.
TIM_ETPS = 00: prescaler disabled.
TIM_ETP = 0: detection of rising edges on ETR and TIM_ECE = 1 to enable the external clock mode 2.
Configure the channel 1 to detect rising edges on TI, as follows:
TIM_IC1F = 0000: no filter.
The capture prescaler is not used for triggering and does not need to be configured.
TIM_CC1S = 01 in the TIMx_CCMR1 register to select only the input capture source.
TIM_CC1P = 0 in the TIMx_CCER register to validate the polarity (and detect rising edge only).
Configure the timer in trigger mode: WriteTIM_SMS = 110 in the TIMx_SMCR register.
Select TI1 as the input source by writing TIM_TS = 101 in the TIMx_SMCR register.
A rising edge on TI1 enables the counter and sets the INT_TIMTIF flag. The counter then counts on ETR rising
edges. The delay between the rising edge of the ETR signal and the actual reset of the counter is due to the
resynchronization circuit on ETRP input.
Figure 10-30. Control circuit in External Clock Mode 2 + Trigger Mode
10.3.15 Timer Synchronization
The two timers can be linked together internally for timer synchronization or chaining. A timer configured in master
mode can reset, start, stop or clock the counter of the other timer configured in slave mode.
Figure 10-31 presents an overview of the trigger selection and the master mode selection blocks.
10.3.15.1 Using One Timer as Prescaler for the Other Timer
For example, to configure Timer 1 to act as a prescaler for Timer 2:
Configure Timer 1 in master mode so that it outputs a periodic trigger signal on each UEV. Writing
TIM_MMS = 010 in the TIM1_CR2 register causes a rising edge to be output on TRGO each time a UEV is
generated.
To connect the TRGO output of Timer 1 to Timer 2, configure Timer 2 in slave mode using ITR0 as an internal
trigger. Write TIM_TS = 100 in the TIM2_SMCR register.
Put the slave mode controller in external clock mode 1: Write TIM_SMS = 111 in the TIM2_SMCR register.
This causes Timer 2 to be clocked by the rising edge of the periodic Timer 1 trigger signal, which corresponds
to the Timer 1 counter overflow.
Finally, enable both timers: Set their respective TIM_CEN bits in the TIMx_CR1 register.
Note:
If OCy is selected on Timer 1 as trigger output (TIM_MMS = 1xx), its rising edge is used to clock the
counter of Timer 2.
Summary of Contents for EMBER EM358 series
Page 2: ...EM358x 2 Rev 0 4 ...
Page 7: ...EM358x Rev 0 4 7 ...