Chapter 13 PWMWord格式.docx
《Chapter 13 PWMWord格式.docx》由会员分享,可在线阅读,更多相关《Chapter 13 PWMWord格式.docx(25页珍藏版)》请在冰豆网上搜索。
![Chapter 13 PWMWord格式.docx](https://file1.bdocx.com/fileroot1/2022-11/15/32b7a39f-55d8-49e8-a61f-55e4416aa828/32b7a39f-55d8-49e8-a61f-55e4416aa8281.gif)
centeralignedoutputmodeandfouravailableclocksources.ThePWMmodulehaseightchannelswithindependentcontrolofleftandcenteralignedoutputsoneachchannel.
Eachoftheeightchannelshasaprogrammableperiodanddutycycleaswellasadedicatedcounter.Aflexibleclockselectschemeallowsatotaloffourdifferentclocksourcestobeusedwiththecounters.Eachofthemodulatorscancreateindependentcontinuouswaveformswithsoftware-selectabledutyratesfrom0%to100%.ThePWMoutputscanbeprogrammedasleftalignedoutputsorcenteralignedoutputs.
13.1.1Features
周期和占空比双缓冲
在有效周期的末尾或通道被禁用,更改才会有效(PWM计数器归零)
8个8位或4个16位PWM通道
Fourclocksources(A,B,SA,andSB)provideforawiderangeoffrequencies
4个时钟源(A,B,SA和SB)提供了广泛的频率
紧急关闭
ThePWMblockincludesthesedistinctivefeatures:
•EightindependentPWMchannelswithprogrammableperiodanddutycycle
•DedicatedcounterforeachPWMchannel
•ProgrammablePWMenable/disableforeachchannel
•SoftwareselectionofPWMdutypulsepolarityforeachchannel
•Periodanddutycyclearedoublebuffered.Changetakeseffectwhentheendoftheeffectiveperiodisreached(PWMcounterreacheszero)orwhenthechannelisdisabled.
•Programmablecenterorleftalignedoutputsonindividualchannels
•Eight8-bitchannelorfour16-bitchannelPWMresolution
•Fourclocksources(A,B,SA,andSB)provideforawiderangeoffrequencies
•Programmableclockselectlogic
•Emergencyshutdown
13.1.2运行模式
可编程禁止时钟进入分频器,以进入低功耗的等待模式。
Freeze模式中有一个软件可编程选项禁止时钟输入分频器。
这对仿真是有益的
Thereisasoftwareprogrammableoptionforlowpowerconsumptioninwaitmodethatdisablestheinputclocktotheprescaler.
Infreezemodethereisasoftwareprogrammableoptiontodisabletheinputclocktotheprescaler.Thisisusefulforemulation.
13.2外部信号描述13.2ExternalSignalDescription
ThePWMmodulehasatotalof8externalpins.该PWM模块共有8外部引脚。
13.2.1PWM7—PWMChannel7
ThispinservesaswaveformoutputofPWMchannel7andPWM通道7作为输入的紧急关断功能
ThispinservesaswaveformoutputofPWMchannel7andasaninputfortheemergencyshutdownfeature.
13.2.2PWM6—PWMChannel6
ThispinservesaswaveformoutputofPWMchannel6.
13.2.3PWM5—PWMChannel5
ThispinservesaswaveformoutputofPWMchannel5.
13.2.4PWM4—PWMChannel4
ThispinservesaswaveformoutputofPWMchannel4.
13.2.5PWM3—PWMChannel3
ThispinservesaswaveformoutputofPWMchannel3.
13.2.6PWM3—PWMChannel2
ThispinservesaswaveformoutputofPWMchannel2.
13.2.7PWM3—PWMChannel1
ThispinservesaswaveformoutputofPWMchannel1.
13.2.8PWM3—PWMChannel0
ThispinservesaswaveformoutputofPWMchannel0.
寄存器中的保留位总是为0
13.3.2RegisterDescriptions
13.3.2.1PWMEnableRegister(PWME)
EachPWMchannelhasanenablebit(PWMEx)tostartitswaveformoutput.WhenanyofthePWMExbitsareset(PWMEx=1),theassociatedPWMoutputisenabledimmediately.However,theactualPWMwaveformisnotavailableontheassociatedPWMoutputuntilitsclocksourcebeginsitsnextcycleduetothesynchronizationofPWMExandtheclocksource.
NOTE
ThefirstPWMcycleafterenablingthechannelcanbeirregular.Anexceptiontothisiswhenchannelsareconcatenated.Onceconcatenatedmodeisenabled(CONxxbitssetinPWMCTLregister),enabling/disablingthecorresponding16-bitPWMchanneliscontrolledbytheloworderPWMExbit.Inthiscase,thehighorderbytesPWMExbitshavenoeffectandtheircorrespondingPWMoutputlinesaredisabled.Whileinrunmode,ifalleightPWMchannelsaredisabled(PWME7–0=0),theprescalercountershutsoffforpowersavings.
1=通道x使能.下一个时钟开始输出PWM
0=通道x禁止
当在16位模式时,使能控制由1;
3;
5;
7位决定。
在16位模式时0,2,4,6位将没有用。
在运行过程中,如果8个通道被关掉,那么预分频记数器也将关掉,为了省电。
PWMEPWME_PWME0-----》PWME_PWME7
IfCON67=1,thenbithasnoeffectandPWMoutputline6isdisabled.
IfCON45=1,thenbithasnoeffectandPWMoutputbit4isdisabled
IfCON23=1,thenbithasnoeffectandPWMoutputbit2isdisabled.
IfCON01=1,thenbithasnoeffectandPWMoutputline0isdisabled.
PWME7:
PulseWidthChannel7Enable
0Pulsewidthchannel7isdisabled.
1Pulsewidthchannel7isenabled.ThepulsemodulatedsignalbecomesavailableatPWMoutputbit7whenitsclocksourcebeginsitsnextcycle.
PWME6:
PulseWidthChannel6Enable
0Pulsewidthchannel6isdisabled.
1Pulsewidthchannel6isenabled.ThepulsemodulatedsignalbecomesavailableatPWMoutputbit6whenitsclocksourcebeginsitsnextcycle.IfCON67=1,thenbithasnoeffectandPWMoutputline6isdisabled.
PWME5: