EasyManuals Logo

ST STM32F10 Series User Manual

ST STM32F10 Series
519 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #185 background imageLoading...
Page #185 background image
UM0306 Advanced control timer (TIM1)
185/519
12.4.17 Timer input XOR function
The TI1S bit in the TIM1_CR2 register, allows the input filter of channel 1 to be connected to
the output of a XOR gate, combining the three input pins TIMx_CH1, TIMx_CH2 and
TIMx_CH3.
The XOR output can be used with all the timer input functions such as trigger or input
capture. An example of this feature used to interface Hall sensors is given in Section 12.4.18
below.
12.4.18 Interfacing with Hall sensors
This is done using the Advanced Control Timer TIM1 timer to generate PWM signals to drive
the motor and another TIMx timer referred to as “interfacing timer” in Figure 67. The
“interfacing timer” captures the 3 timer input pins (CC1, CC2, CC3) connected through a
XOR to the TI1 input channel (selected by setting the TI1S bit in the TIMx_CR2 register).
The slave mode controller is configured in reset mode; the slave input is TI1F_ED. Thus,
each time one of the 3 inputs toggles, the counter restarts counting from 0. This creates a
time base triggered by any change on the Hall inputs.
On the “interfacing timer”, capture/compare channel 1 is configured in capture mode,
capture signal is TRC (See Figure 50: Capture/compare channel (example: channel 1 input
stage) on page 167). The captured value, which corresponds to the time elapsed between 2
changes on the inputs, gives information about motor speed.
The “interfacing timer” can be used in output mode to generate a pulse which changes the
configuration of the channels of the TIM1 timer (by triggering a COM event). The TIM1 timer
is used to generate PWM signals to drive the motor. To do this, the interfacing timer channel
must be programmed so that a positive pulse is generated after a programmed delay (in
output compare or PWM mode). This pulse is sent to the TIM1 timer through the TRGO
output.
Example: you want to change the PWM configuration of your Advanced Control Timer TIM1
timer after a programmed delay each time a change occurs on the Hall inputs connected to
one of the TIMx timers.
Configure 3 timer inputs ORed to the TI1 input channel by writing the TI1S bit in the
TIMx_CR2 register to ‘1’,
Program the time base: write the TIMx_ARR to the max value (the counter must be
cleared by the TI1 change. Set the prescaler to get a maximum counter period longer
than the time between 2 changes on the sensors,
Program the channel 1 in capture mode (TRC selected): write the CC1S bits in the
TIMx_CCMR1 register to ‘01’. You can also program the digital filter if needed,
Program the channel 2 in PWM 2 mode with the desired delay: write the OC2M bits to
‘111’ and the CC2S bits to ‘00’ in the TIM1_CCMR1 register,
Select OC2REF as trigger output on TRGO: write the MMS bits in the TIMx_CR2
register to ‘101’,
In the Advanced Control Timer TIM1 timer, the right ITR input must be selected as trigger
input, the timer is programmed to generate PWM signals, the capture/compare control
signals are preloaded (CCPC=1 in the TIM1_CR2 register) and the COM event is controlled
by the trigger input (CCUS=1 in the TIM1_CR2 register). The PWM control bits (CCxE,
OCxM) are written after a COM event for the next step (this can be done in an interrupt
subroutine generated by the rising edge of OC2REF).
www.BDTIC.com/ST

Table of Contents

Other manuals for ST STM32F10 Series

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the ST STM32F10 Series and is the answer not in the manual?

ST STM32F10 Series Specifications

General IconGeneral
BrandST
ModelSTM32F10 Series
CategoryMicrocontrollers
LanguageEnglish

Related product manuals