Advanced control timer (TIM1)
The "interfacing timer" can be used in output mode to generate a pulse which changes the
configuration of the channels of the advanced control timer TIM1 (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 advanced
control timer TIM1 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).
The
Figure 68
182/501
describes this example.
RM0008
Need help?
Do you have a question about the STM32F101 Series and is the answer not in the manual?