
EM358x
180
Rev. 0.4
To control the output waveform, software can update the TIMx_CCRy register at any time, provided that the buffer
register is not enabled (TIM_OCyBE = 0). Otherwise TIMx_CCRy shadow register is updated only at the next
UEV. An example is given in Figure 10-21.
Figure 10-21. Output Compare Mode, Toggle on OC1
10.3.9 PWM Mode
Pulse width modulation mode allows you to generate a signal with a frequency determined by the value of the
TIMx_ARR register, and a duty cycle determined by the value of the TIMx_CCRy register.
PWM mode can be selected independently on each channel (one PWM per OCy output) by writing 110 (PWM
mode 1) or 111 (PWM mode 2) in the TIM_OCyM bits in the TIMx_CCMR1 register. The corresponding buffer
register must be enabled by setting the TIM_OCyBE bit in the TIMx_CCMR1 register. Finally, in up-counting or
center-aligned mode the auto-reload buffer register must be enabled by setting the TIM_ARBE bit in the
TIMx_CR1 register.
Because the buffer registers are only transferred to the shadow registers when a UEV occurs, before starting the
counter initialize all the registers by setting the TIM_UG bit in the TIMx_EGR register.
OCy polarity is software programmable using the TIM_CCyP bit in the TIMx_CCER register. It can be
programmed as active high or active low. OCy output is enabled by the TIM_CCyE bit in the TIMx_CCER register.
Refer to the TIMx_CCER register description in the Registers section for more details.
In PWM mode (1 or 2), TIMx_CNT and TIMx_CCRy are always compared to determine whether
TIMx_CCRy ≤ TIMx_CNT or TIMx_CNT ≤ TIMx_CCRy, depending on the direction of the counter. The OCyREF
signal is asserted only:
When the result of the comparison changes, or
When the output compare mode (TIM_OCyM bits in the TIMx_CCMR1 register) switches from the “frozen”
configuration (no comparison, TIM_OCyM = 000) to one of the PWM modes (TIM_OCyM = 110 or 111).
This allows software to force a PWM output to a particular state while the timer is running.
The timer is able to generate PWM in edge-aligned mode or center-aligned mode depending on the TIM_CMS
bits in the TIMx_CR1 register.
10.3.9.1 PWM Edge-Aligned Mode: Up-Counting Configuration
Up-counting is active when the TIM_DIR bit in the TIMx_CR1 register is low. Refer to the section Up-Counting
Mode.
The following example uses PWM mode 1. The reference PWM signal OCyREF is high as long as
TIMx_CNT < TIMx_CCRy, otherwise it becomes low. If the compare value in TIMx_CCRy is greater than the
Содержание EMBER EM358 series
Страница 2: ...EM358x 2 Rev 0 4 ...
Страница 7: ...EM358x Rev 0 4 7 ...