286
/
838
Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
Figure 11-21 Output compare mode, toggle on OC1
11.3.10
PWM mode
User can use PWM mode to generate a signal whose duty cycle is determined by the value of the TIMx_CCDATx
register and whose frequency is determined by the value of the TIMx_AR register. And depends on the value of
TIMx_CTRL1.CAMSEL, the TIM can generate PWM signal in edge-aligned mode or center-aligned mode.
User can set PWM mode 1 or PWM mode 2 by setting TIMx_CCMODx. OCxMD=110 or setting TIMx_CCMODx.
OCxMD=111. To enable preload register, user must set corresponding TIMx_CCMODx.OCxPEN. And then set
TIMx_CTRL1.ARPEN to auto-reload preload register eventually.
User can set polarity of OCx by setting TIMx_CCEN.CCxP. On the other hand, to enable the output of OCx, user
need to set the combination of the value of CCxEN, CCxNEN, MOEN, OSSI, and OSSR in TIMx_CCEN and
TIMx_BKDT.
The values of TIMx_CNT and TIMx_CCDATx are always compared with each other when the TIM is under PWM
mode.
Only if an update event occurs, the preload register will transfer to the shadow register. Therefore user must reset all
the registers by setting TIMx_EVTGEN.UDGN before the counter starts counting.
PWM center-aligned mode
If user set TIMx_CTRL1.CAMSEL equal 01, 10 or 11, the PWM center-aligned mode will be active. The setting of
the compare flag depends on the value of TIMx_CTRL1.CAMSEL. There are three kinds of situation that the
compare flag is set, only when the counter counts up, only when the counter counts down, or when the counter counts
up and counts down. User should not modified TIMx_CTRL1.DIR by software, it is updated by hardware.
TIM1_CNT
8800
8801
006B
006A
0069
TIM1_CCDAT1
OC1REF=OC1
006A
Match detected on CCDAT1
Interrupt generated if enabled
Write 8801h in CCDAT1
register
8801