msp430 ti套件lm3slib pwm第1章脉冲宽度调制_第1页
msp430 ti套件lm3slib pwm第1章脉冲宽度调制_第2页
msp430 ti套件lm3slib pwm第1章脉冲宽度调制_第3页
msp430 ti套件lm3slib pwm第1章脉冲宽度调制_第4页
msp430 ti套件lm3slib pwm第1章脉冲宽度调制_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

( 函数voidPWMGenConfigure(nsigedlongulBase,nsigedlonulGen,nsigedlonguC5voidPWMGenPeriodSet(nsigedlongulBase,nsigedlonulGen,nsigedlonguP6nsigedlongPWMGenPeriodGet(nsigedlongulBase,nsiged 7voidPWMPulseWidthSet(nsigedlongulBase,nsigedlonguPWMOut,nsigedlongl7nsigedlongPWMPulseWidthGet(nsigedlongulBase,nsigedlonguP7voidPWMGenEnable(nsigedlongulBase,nsiged 8voidPWMGenDisable(nsigedlongulBase,nsiged 8voidPWMDeadBandEnable(nsiged nsiged nsigndshort nsigndshortuFall8voidPWMDeadBandDisable(nsigedlongulBase,nsiged 9voidPWMSyncUpdate(nsigedlongulBase,nsigedlongule9voidPWMSyncTimeBase(nsigedlongulBase,nsigedlongulenvoidPWMOutputState(nsigedlongulBase,nsigedlongulPWMutBits,BooleanEnvoidPWMOutputInvert(nsigedlongulBase,nsigedlongulPWMutBits,BooleanInvoidPWMOutputFaultLevel(nsiged nsigedlongulPWM BooleanbDrveigh)voidPWMOutputFault(nsiged nsigedlongulPWM BooleanbFaultSppess)voidPWMGenIntRegister(nsigedlongulBase,nsigedlonulGn,void(*pfnIntHandler(vvoidPWMGenIntUnregister(nsigedlongulBase,nsigedlonuvoidPWMGenIntTrigEnable(nsigedlongulBase,nsigedlonulGen,nsigedlongulntvoidPWMGenIntTrigDisable(nsigedlongulBase,nsigedlonulGen,nsigedlongulntnsigedlongPWMGenIntStatus(nsigedlongulBase,nsigedlonulGen,BooleanMavoidPWMGenIntClear(nsigedlongulBase,nsigedlonulGen,nsigedlongulvoidPWMGenFaultConfigure(nsigednsigednsigedlongulMinFaulnsigedlongulFaulSeses)voidPWMGenFaultTriggerSet(nsigednsigedlonnsigedlongnsigedlongulFaultTignsigedlongPWMGenFaultTriggerGet(nsigednsigednsigedlonglGunsignedlongPWMGenFaultStatus(unsignedlongunsignedlongulGen,voidPWMGenFaultClear(unsignedlongunsignedlongunsignedlongulGroup,voidPWMFaultIntRegister(unsignedlongulBase,voidvoidPWMFaultIntUnregister(unsignedlongvoidPWMFaultIntClear(unsignedlongvoidPWMFaultIntClearExt(unsignedlongulBase,unsignedlongvoidPWMIntEnable(unsignedlongulBase,unsignedlongvoidPWMIntDisable(unsignedlongulBase,unsignedlongunsignedlongPWMIntStatus(unsignedlongulBase,tBooleanPWMPWMModulation器来产生方波,并且可以通过调整方波的占空比来对模拟信号电平进行编码。PWM通常使StellarisARM4PWMPWM发生器模1个定时器(16位递减或先递增后递减计数器、2个比较器、1PWM信号发生器、1个死区发生器,以及一个中断/ADCPWM信号的极PWMPWMPWM信号可以是独立的信号(基于同一定时器因而频率相同的独立信号除外),也可以是一对插入了死区延迟的互补StellarisPWMPWM信号,如简易充电泵需要的信号;也可以产生带死区延迟的成对PWM信号,如半-H桥(half-HStellarisARMPWMPWM发生器运作时,定时器在不断计数并和两个比较器的值进行比较,可以在和比较器16PWM1.11.1PWMD/A1.2PWMPWM定时器有两种工作模式:递减计数模式或先递增后递减计数模式。在递减计数模PWM信号,而先递增后递减计数模式是用来产生中心对齐的PWM信号。PWM3PWM信号的过程中使用。一个是方向信平之间切换0时,零脉冲信号发PWMPWM信号的过程中使用。如果任一比较器的值大于计数器的装载值,则该比较器永远不会左对齐的一对PWM波形。1.3左对齐PWM1.4中心对齐PWMbridge1.5PWM运行(即令PWM输出无效,以避免其长时间处于危险的运行状态。FaultPWM信号输PWM5种信号:zero、load、dir、cmpA、cmpB都可以触发中断,或者触发ADC转换。使控制非常灵活。PWMGenConfigure()PWM发生器模式进行设置,包括定时器的计数模()PWMPulseWidthSet(PWMPWMPWMGenPeriodSet()里设置的值,也就是占空比不能大于100%。调用函数PWMGenEnablePWMPWM发送器的定时器开始运作。反之函数PWMGenDisable()则禁止PWM定时器运作。1.1PWMGenConfigure(voidPWMGenConfigure(unsignedlongulBase,unsignedlongulGen,unsignedlongulBase:PWMulGen:PWM // //发生器不同步模式PWM_GEN_MODE_GEN_SYNC_LOCAL//发生器局部同步模式PWM_GEN_MODE_GEN_SYNC_GLOBAL//全局发生器同步模式 //不同步 //局部同步PWM_GEN_MODE_DB_SYNC_GLOBAL//全局发生器同步模式 PWM_GEN_MODE_FAULT_UNLATCHED// //PWM_GEN_MODE_FAULT_NO_MINPER// //Fault0 //PWMnFLTSRC0无1.2PWMGenPeriodSetvoidPWMGenPeriodSet(unsignedlongulBase,unsignedlongulGen,unsignedlongulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:无1.3PWMGenPeriodGetunsignedlongPWMGenPeriodGet(unsignedlongulBase,unsignedlongulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:1.4PWMPulseWidthSet(voidPWMPulseWidthSet(unsignedlongulBase,unsignedlongulPWMOut,unsignedlongulBase:PWM端口的基址,取值PWM_Base PWM的高电平宽度,宽度值是PWM无1.5PWMPulseWidthGet(unsignedlongPWMPulseWidthGet(unsignedlongulBase,unsignedlongulBase:PWM端口的基址,取值PWM_Base PWM的高电平宽度,宽度值是PWM计数器的计时时钟数,类型为unsignedlong1.6PWMGenEnable(voidPWMGenEnable(unsignedlongulBase,unsignedlongulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:无1.7PWMGenDisable(voidPWMGenDisable(unsignedlongulBase,unsignedlongulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:无PWMDeadBandEnablePWM发生器的死区时间,并打开死区功能,脉冲个数。调用该函数配置好后,PWMPWM就是一对带死区的反相的1.8PWMDeadBandEnable(voidPWMDeadBandEnable(unsignedlongunsignedlongulGen,unsignedshortunsignedshortulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:无1.9PWMDeadBandDisable(voidPWMDeadBandDisable(unsignedlongulBase,unsignedlongulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:无PWMSyncUpdate(PWM发生器所挂起的PWMSyncTimeBasePWMPWM发生器1.10PWMSyncUpdate(voidPWMSyncUpdate(unsignedlongulBase,unsignedlong 无1.11PWMSyncTimeBase(voidPWMSyncTimeBase(unsignedlongulBase,unsignedlong 无PWMOutputState()8PWMPWM发生器产生的PWM信号是否输出到管脚的最后一个开关。果bInvert为1,则反相PWM信号。PWMOutputFaultLevel()PWM的故障状态时,PWM管脚的默认输出1.12PWMOutputState(voidPWMOutputState(unsignedlongulBase,unsignedlongulPWMOutBits,tBoolean PWM端口的基址,取值PWM_Base 无1.13PWMOutputInvert(voidPWMOutputInvert(unsignedlongulBase,unsignedlongulPWMOutBits,tBoolean PWM端口的基址,取值PWM_Base 无1.14PWMOutputFaultLevelvoidPWMOutputFaultLevel(unsignedlongtBooleanbDriveHigh) PWM端口的基址,取值PWM_Base 无1.15PWMOutputFault(voidPWMOutputFault(unsignedlongtBooleanbFaultSuppress) PWM端口的基址,取值PWM_Base //故障时输出PWMOutputFaultLevel() 无PWM发生器有丰富的中断和触发源,能在很多时刻产生中断,使中断变得非常灵活。对应的函数PWMGenIntUnregister()对已注册的PWM发生器中断函数注销。PWMGenIntTrigEnableADC的事件进行使能,通过使能的ADCulIntTrig126个是中断的时间,6个是ADC触发时间。在递减计数时,只有8个事件是有效的。PWMGenIntTrigDisable()对触发事件进行禁能。起作用和上面的函数PWMGenIntTrigEnable()相反。PWMGenIntClear用来清除指定的中断状态,应该在进入中断服务函数中,在获1.16PWMGenIntRegister(注册一个指定PWMvoidPWMGenIntRegister(unsignedlongulBase,unsignedlongulGen,voidulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:无1.17PWMGenIntUnregister(voidPWMGenIntUnregister(unsignedlongulBase,unsignedlongulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:无1.18PWMGenIntTrigEnable(voidPWMGenIntTrigEnable(unsignedlongulBase,unsignedlongulGen,unsignedlongulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:ulIntTrig:PWM发生器的中断和触发事件选择,取下列值的逻辑或: //计数器为0时,触发中断 //计数器为装载值时,触发中断 //比较器A递增匹配时,触发中断 //比较器A递减匹配时,触发中断 //比较器B递增匹配时,触发中断 //比较器B递减匹配时,触发中断 //计数器为0时,触发ADC //计数器为装载值时,触发ADC //比较器A递增匹配时,触发ADC //比较器A递减匹配时,触发ADC //比较器B递增匹配时,触发 比较器B无1.19PWMGenIntTrigDisable(voidPWMGenIntTrigDisable(unsignedlongulBase,unsignedlongulGen,unsignedlongulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:ulIntTrig:PWM发生器的中断和触发事件选择,取下列值的逻辑或: //计数器为0时,触发中断 //计数器为装载值时,触发中断 //比较器A递增匹配时,触发中断 //比较器A递减匹配时,触发中断 //比较器B递增匹配时,触发中断 //比较器B递减匹配时,触发中断 //计数器为0时,触发ADC //计数器为装载值时,触发ADC //比较器A递增匹配时,触发ADC //比较器A递减匹配时,触发ADC //比较器B递增匹配时,触发 比较器B无1.20PWMGenIntStatus(unsignedlongPWMGenIntStatus(unsignedlongulBase,unsignedlongulGen,tBooleanulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一: 1.21PWMGenIntClear(voidPWMGenIntClear(unsignedlongulBase,unsignedlongulGen,unsignedlongulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一: //计数器为0触发的中断 //计数器为装载值触发的中断 //比较器A递增匹配触发的中断 //比较器A递减匹配触发的中断 //比较器B递增匹配触发的中 比较器B无PWMGenFaultConfigure(PWM发生器的故障检测管脚电平和最小故障PWMGenConfigure()PWM_GEN_MODE_FAULT_函数PWMGenFaultTriggerSet()用来选择用哪些Fault引脚作为指定的PWM发生器的错PWMGenFaultTriggerGet(Fault1.22PWMGenFaultConfigure(voidPWMGenFaultConfigure(unsignedlongunsignedlongunsignedlongulFaultSenses)ulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:ulMinFaultPeriod:最小故障激活保持时长,PWM 无1.23PWMGenFaultTriggerSet(voidPWMGenFaultTriggerSet(unsignedlongunsignedlongunsignedlongulGroup,ulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:ulFaultTriggers:定义指定的PWM发生器使用哪个故障输入作为触发端,对于无1.24PWMGenFaultTriggerGetnsignedlongPWMGenFaultTriggerGet(unsignedlongunsignedlongulGen,ulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:1.25PWMGenFaultStatus(unsignedlongPWMGenFaultStatus(unsignedlongunsignedlongulGen,ulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:1.26PWMGenFaultClear(voidPWMGenFaultClear(unsignedlongunsignedlongunsignedlongulGroup,ulBase:PWM端口的基址,取值PWM_BaseulGen:PWM发生器的编号,取下列值之一:无)建议使用PWMFaultIntClearExt()。)1.27PWMFaultIntRegistervoidPWMFaultIntRegister(unsignedlongulBase,void 无1.28PWMFaultIntUnregistervoidPWMFaultIntUnregister(unsignedlongulBase:PWM无1.29PWMFaultIntClearvoidPWMFaultIntClear(unsignedlongulBase:PWM无1.30PWMFaultIntClearExt(voidPWMFaultIntClearExt(unsignedlongulBase,unsignedlongulBase:PWM端口的基址,取值PWM_Base无PWMIntEnable(PWM发生器的中断和故障中断。PWMIntDisable()1.31PWMIntEnable(voidPWMIntEnable(unsignedlongulBase,unsignedlongulBase:PWM端口的基址,取值PWM_Base无1.32PWMIntDisable(voidPWMIntDisable(unsignedlongulBase,unsignedlongulBase:PWM端口的基址,取值PWM_Base1.33PWMIntStatus(unsignedlongPWMIntStatus(unsignedlongulBase,tBoolean 端口的基址,取值 PWM1.1产生两路简单#include"hw_types.h"#include"sysctl.h"#include"gpioh"#include"pwm#define#definePH1_PWM3#defineKEY_PERIPH#defineKEY_PORT#defineintmain{SYSCTL_USE_OSC|SYSCTL_OSC_MAIN/*8MHz外部晶振作为主时钟SysCtlPeripheralEnable/*使能KEYGPIO/*设置KEYif(GPIOPinRead(KEY_PORT,KEY_PIN)=={for}/*若复位时按下KEY/*PWM/*PWMPWM_GEN_MODE_UP_DOWNPWM_GEN_MODE_UP_DOWN|PWMGenPeriodSet(PWM_BASE,PWM_GEN_1,PWMPulseWidthSet(PWM_BASE,PWM_OUT_2,PWMPulseWidthSet(PWM_BASE,PWM_OUT_3,/*设置PWM发生器1/*PWM2/*PWM3PWMOutputState(PWM_BASE,(PWM_OUT_2_BIT|PWM_OUT_3_BIT),/*PWM2和PWM3PWMGenEnable(PWM_BASE,/*PWM/*开始产生PWM沿延时10µs。1.2带死区PWMSysCtlPeripheralEnable使能KEYGPIO设置KEY/*设置PWM2输出的脉冲宽 /*使能PWM死区,并设置死区延 设置上升沿延时设置下降沿延时PWM_OUT_2_BIT|PWM2和PWM3开始产生PWMfor(;;)}1.3PWM#include"hw_types.h"#include"hw_ints.h"#include"interrupth"#include"sysctl.h"#include"gpioh"#include"pwmintmain{SysCtlClockSet(SYSCTL_SYSDIV_1| /*8MHz外部晶振作为主时钟*/SYSCTL_USE_OSC|SYSCTL_OSC_MAIN|SysCtlPeripheralEnable /*使能KEY所在的GPIO端 /*设置KEY所在管脚为输 if(GPIOPinRead(KEY_PORT,KEY_PIN)== /*若复位时按下KEY,则进 {for /*死循环,以等待JTAG连 } /*使能PWM2和PWM3输出所在GPIO*/ /*使能PWM模块 /*PWM时钟配置:不分频GPIOPinTypePWM(GPIO_PORTH_BASE,GPIO_PIN_0);/*PH0和PH1配置为PWM功能*/PWM

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论