PWM模块和时钟系统模块学习笔记

上传人:hs****ma 文档编号:431646516 上传时间:2022-11-29 格式:DOCX 页数:6 大小:81.75KB
返回 下载 相关 举报
PWM模块和时钟系统模块学习笔记_第1页
第1页 / 共6页
PWM模块和时钟系统模块学习笔记_第2页
第2页 / 共6页
PWM模块和时钟系统模块学习笔记_第3页
第3页 / 共6页
PWM模块和时钟系统模块学习笔记_第4页
第4页 / 共6页
PWM模块和时钟系统模块学习笔记_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《PWM模块和时钟系统模块学习笔记》由会员分享,可在线阅读,更多相关《PWM模块和时钟系统模块学习笔记(6页珍藏版)》请在金锄头文库上搜索。

1、PWM 模块1. PWM 通道占空比寄存器 PWM Channel Duty Register (PWMDTY)Module Base + QxOOIC = PWDTYO, 0x0010- PWMDTY1, 0x00IE = PWMDTY2H 0x001 F - PWMDTY3 Mod u Is* 0x0020 = PWMDTY4. 0x0021 = PV/MDTY5. 0k0022 = PWMDTY6, 0x0023 = PWMDTY77654321Bit 765斗32”Bit a11111111Figure 13-16. PWM Channel Duty Registers (PWMDTY

2、x)Read: Anytime每个通道都有一个专用的用来设置占空比的寄存器PWMDTYx, PWMDTYx和PWMPERx 的值共同决定了占空比的值,就是说当每个通道的count的值计数到与PWMDTYx的值 相等时,相应的输出信号就发生一次翻转。如果你设置 PWMPOL 寄存器的某位 PPOLx 的值为1,也就是开始的时候输出为高电平,然后当计数器数到与PWMDTYx的值后就 翻转为低电平,那么 PWMDTY 寄存器的值就包含了高电平的时间,再结合占空比说明 一下吧PPOLx=1:占空比=(PWMDTYx/PWMPERx) *100%PPOLx=0:占空比=( PWMPERx-PWMDTYx

3、) /PWMPERx*100%2. PWM 通道周期寄存器 PWM Channel Period Registers(PWMPERx)ModuIe Base * 0x0014 = PWMPER0,0x0015= PYVMPER1. 0x0016 = PWMPER2. 0x001 ? = PWHPER3 Mcdule Da?e + 0x001 fl = PWMPER4, CudDT = PWMPER? M01A = PWMPERfi DkOOIB- PAMPER?7e543210Bit 7654321BiiOReset11111111Figure 13-15. PWM Channel Perio

4、d Rgistrs (PWMPERx)Read: AnytimeWrite: Any Li me每个通道都有一个专用的用来设置周期情况的寄存器(PWMPERx),这个寄存器的值就决定 了 PWM 通道输出信号周期的长短,如果我们已经知道的参考时钟源的值,那么就可以计算 出PWM输出信号的周期了,计算方法如下:PWMxPeriod=ChannelClockPeriod*PWMPERx(左对齐情况下即 CAEx=0) PWMxPeriod=ChannelClockPeriod*PWMPERx*2(居中对齐情况下即 CAEx=1)3 PWM 使能寄存器 PWM Enable Register(PWM

5、E)Module Baaa + 0x03007bS斗321CPWME7PWME6PWME4PWM曰PVME2PWME1PWMEO0D00000DFiguire 13-3- PWM Enable Register pWME)PWME7:0分别控制着对应的8个通道的使能,例如:PWME_PWMEO=O:禁止通道0的PWM输出PWME_PWME7=1: 使能通道 7 的 PWM 输出3. PWM 极 性 寄 存 器 PWM Polarity Register(PWMPOL)13-3.2,2 PWM Polarity Register (PWMPOL)The starting polarity of

6、each PWKl channel waveibrm is tletrrmineil by the a&dcialeLl PPOLx bn in the PViMPOL register. If the polarity bit is one, the 卩 char nel output i s high at the beginning of the cycle acid llien goei low wheti Lhe duty count ii reached. CemvrrieljL if the polarity bii 冷 zerD4 llic cmtpul stalls low

7、and then goes high when the duty count is reached,Modu a asc - ta00017654321QPPOL7PPOL6PPOL5PPOL4PPOL3PPOL2POLIPPOLO0D00D000Figure 13-4. PWM Polarity Register (PWMPOLRead: AnyiimeWrite: AnytiincPWMPOL寄存器是用来控制PWM 一开始输出时的信号高低情况,假如PPOLX设为1则与 之相应的PWM通道在开始的时候输出为高电平,然后等到计数器的值与你设置的那个PWM 信号的值(PWMDTYx)相等的时候就

8、输出低电平。PPOL的值为0的时候正好与这相反。4. PWM Clock Select Register(PWM 时钟选择寄存器)lodu & Bago + 0kG00275斗3210PCLK7PCLKL6PCLK5PCLK4PCLK3PGLK2PCLK1PGLKD0000Q000Figure 13-i PWM Clock Select Register (PWMCLK)Read: AnytimeWrite: AnytimeNOTERegister bits PCLKO to PCI.KJ can be written anytime. If a clock select is c bange

9、d while a PWM signal is bling geneiaLed; n Lnuicaltxl or sir 亡 teheed pulse can occur during the transition.PWMCLK寄存器是用来设置每个通道的参考时钟源的,每个通道都有2个时钟源,具体的为 CLOCK A,CLOCK SA(0,1,4,5);CLOCK B,CLOCK SB(2,3,6,7) ,例如:PWMCLK_PCLK0=0;则通道0选择CLOCK A作为时钟源PWMCLK_PCLK6=1;则通道6选择CLOCK SB作为参考时钟源5. PWM Prescale Clock Se

10、lect Register(PWMPRCLK)PWM 预分频时钟选择寄存器7:ta?2io0PCKB2PCKS1PCKB0DPCKA2PCKA1PCKA0Res1 00D:0:00=Unimplsimenied 口r ReservedFigure 13-6. PWM Pascal? Clock Select Register (PWMPFCLK)Rend: Any limeWriie: AnyrimePWMPRCLK的第3位和第7位没有定义,低三位用来设置CLOCK A的分频,4-6位则设置CLOCKB 的 分 频 , 以 CLOCK A 为 例 , 具 体 值 的 计 算 如 下 表 :Ta

11、ble 13-6. Glock A Prescaler SelectsPCKA2PCKA1PCKA0Value of Clock A000Bus clock001Bus dock / 2010Bls dock/4011Bls dock/8100Bus clock J 16101Bus clock732110Bus clock / 64111Bus cloak 11236、PWM Center Align Enable Register(PWMCAE)The PWM CAE register conliiiii eight conirul bits for the ekcticn of cent

12、er aligned cmtpuTs or left aligned cutiLibi for 亡 a ch PW X-I channel. If the CAEs bit is set to a one? the corresp ending 卩 XV M output will he ccnler aligned. Jlthe CAEk bit is cleared tlie coir亡!iRCinlin PWM ouLpul il. be left aliened. See Section l j.4.2.55 Teft Aligned Outputs1 and Section 13.4

13、.2.6. Center Aligned Output for a more dmiled descnpti&n df the 卩WM output modes.Module Base + OxflOtM76543210CAE7CAE6CAE5CAE4CAE3CAE2CAE1CAEOD000000aFigure 113-7. FWM Center Align Enable Register (PWMCAE)Itrad: AnylimeWrite: AnytimePWMCAE寄存器用来设置每个通道的对齐方式,CAEx为0时,设置相应的通道为左对齐,CAEx为1时,设置相应的通道为中心对齐7、PW

14、M Control Register (PWMCTL)The PWMCTL rtgisler pnivitki for Mrious contno(if the PW1 module.Modu q Bast + Dx0005PWMCTL寄存器可以控制相应通道之间的两两级联情况,以便将PWM 口设置成16位的输 出,这样有利于提高精度,比如你设置PWMCTL_CON01=1;那么通道0和通道1就级联成一 个16位的PWM输出通道,这个16位的PWM通道的输出端为通道1的输出端口,其配置 情况也由通道1的相应寄存器去设置。8、PWM Scale A Rerister(PWMSCLA)PWMSCLA寄存器是用来将CLOCK A寄存器继续压缩分频,以产生CLOCK SA,具体的计算 公式如下:CLOCK SA=CLOCK/2*PWMSCLA注意:当PWMSCLA为0的时候实际上是满标度值,也就是将COLCK A 512分频 寄存器各位如下所示Module Base + OkOOOB7543210Bit 754321Biia0000Q00D

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 建筑资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号