完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
本帖最后由 一只耳朵怪 于 2018-6-7 10:14 编辑
本人用tms320F28035做永磁同步电机控制,将Epwm1/2/3配置成互补的PWM输出,时钟同步上将ePWM1为主pwm,epwm2/3为从pwm。实验时出现奇怪的现象:有时候上电后,epwm1/2/3都能正常输出;有时候上电后,epwm1能够正常输出,epwm2/3没有输出(都是直接测量的DSP管脚)。请问,这可能是什么原因? PWM配置代码如下: //------------------------------------------------------------- //初始化Epwm1的寄存器 //------------------------------------------------------------- void InitEPwm1(void) [ EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; EDIS; // Setup TBCLK EPwm1Regs.TBPRD = 3000; // Set timer period 801 TBCLKs EPwm1Regs.TBCTR = 0x0000; // Clear counter EPwm1Regs.TBCTL.bit.PHSDIR = 0; EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0 // Set Compare values EPwm1Regs.CMPA.half.CMPA = 1500; // Set compare A Init value EPwm1Regs.CMPB = 1500; // Set Compare B Init value // Setup counter mode EPwm1Regs.TBCTL.bit.CTRMODE = 0x2; // Up-dowm Counter mode EPwm1Regs.TBCTL.bit.PHSEN = 0; // Master Module EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0x0; // Clock ratio to SYSCLKOUT EPwm1Regs.TBCTL.bit.CLKDIV = 0x0; //60MHZ/(1*1) = 60MHZ,EPWM模块始终频率为60MHZ EPwm1Regs.TBCTL.bit.PRDLD = 0; EPwm1Regs.TBCTL.bit.SYNCOSEL = 1; // Setup shadowing EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0x0; EPwm1Regs.CMPCTL.bit.SHDWBMODE = 0x0; EPwm1Regs.CMPCTL.bit.LOADAMODE = 0x0; // Load on Zero EPwm1Regs.CMPCTL.bit.LOADBMODE = 0x0; // Set actions EPwm1Regs.AQCTLA.bit.CAU = 0x2; // Set PWM1A High on event A, up count EPwm1Regs.AQCTLA.bit.CAD = 0x1; // Clear PWM1A Low on event A, down count EPwm1Regs.AQCTLB.bit.CBU = 0x1; EPwm1Regs.AQCTLB.bit.CBD = 0x2; // ENABLE TRIG ADC EPwm1Regs.ETSEL.bit.SOCAEN = 1; // EPwm1Regs.ETSEL.bit.SOCASEL = 1; // EPwm1Regs.ETPS.bit.SOCAPRD = 1; EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; EDIS; ] //------------------------------------------------------------- //初始化Epwm2的寄存器 //------------------------------------------------------------- void InitEPwm2(void) [ EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; // DISEnable TBCLK within the ePWM EDIS; // Setup TBCLK EPwm2Regs.TBPRD = 3000; // Set timer period 801 TBCLKs EPwm2Regs.TBCTR = 0x0000; // Clear counter EPwm2Regs.TBCTL.bit.PHSDIR = 1; EPwm2Regs.TBPHS.half.TBPHS = 0x0002; // Phase is 2 // Set Compare values EPwm2Regs.CMPA.half.CMPA = 1500; // Set compare A Init value EPwm2Regs.CMPB = 1500; // Set Compare B Init value // Setup counter mode EPwm2Regs.TBCTL.bit.CTRMODE = 2; // Up-dowm Counter mode EPwm2Regs.TBCTL.bit.PHSEN = 1; // Slave Module EPwm2Regs.TBCTL.bit.HSPCLKDIV = 0; // Clock ratio to SYSCLKOUT EPwm2Regs.TBCTL.bit.CLKDIV = 0; //60MHZ/(1*1) = 60MHZ,EPWM模块始终频率为60MHZ EPwm2Regs.TBCTL.bit.PRDLD = 0; EPwm2Regs.TBCTL.bit.SYNCOSEL = 0; // Setup shadowing EPwm2Regs.CMPCTL.bit.SHDWAMODE = 0; EPwm2Regs.CMPCTL.bit.SHDWBMODE = 0; EPwm2Regs.CMPCTL.bit.LOADAMODE = 0; // Load on Zero EPwm2Regs.CMPCTL.bit.LOADBMODE = 0; // Set actions EPwm2Regs.AQCTLA.bit.CAU = 2; // Set PWM2A High on event A, up count EPwm2Regs.AQCTLA.bit.CAD = 1; // Clear PWM2A Low on event A, down count EPwm2Regs.AQCTLB.bit.CBU = 1; EPwm2Regs.AQCTLB.bit.CBD = 2; EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // DISEnable TBCLK within the ePWM EDIS; ] //------------------------------------------------------------- //初始化Epwm3的寄存器 //------------------------------------------------------------- void InitEPwm3(void) [ EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; // DISEnable TBCLK within the ePWM EDIS; // Setup TBCLK EPwm3Regs.TBPRD = 3000; // Set timer period 801 TBCLKs EPwm3Regs.TBCTR = 0x0000; // Clear counter EPwm3Regs.TBCTL.bit.PHSDIR = 1; EPwm3Regs.TBPHS.half.TBPHS = 0x0002; // Phase is 2 // Set Compare values EPwm3Regs.CMPA.half.CMPA = 1500; // Set compare A Init value EPwm3Regs.CMPB = 1500; // Set Compare B Init value // Setup counter mode EPwm3Regs.TBCTL.bit.CTRMODE = 2; // Up-dowm Counter mode EPwm3Regs.TBCTL.bit.PHSEN = 1; // Slave Module EPwm3Regs.TBCTL.bit.HSPCLKDIV = 0; // Clock ratio to SYSCLKOUT EPwm3Regs.TBCTL.bit.CLKDIV = 0; //60MHZ/(1*1) = 60MHZ,EPWM模块始终频率为60MHZ EPwm3Regs.TBCTL.bit.PRDLD = 0; EPwm3Regs.TBCTL.bit.SYNCOSEL = 0; // Setup shadowing EPwm3Regs.CMPCTL.bit.SHDWAMODE = 0; EPwm3Regs.CMPCTL.bit.SHDWBMODE = 0; EPwm3Regs.CMPCTL.bit.LOADAMODE = 0; // Load on Zero EPwm3Regs.CMPCTL.bit.LOADBMODE = 0; // Set actions EPwm3Regs.AQCTLA.bit.CAU = 2; // Set PWM3A High on event A, up count EPwm3Regs.AQCTLA.bit.CAD = 1; // Clear PWM3A Low on event A, down coun EPwm3Regs.AQCTLB.bit.CBU = 1; EPwm3Regs.AQCTLB.bit.CBD = 2; EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // DISEnable TBCLK within the ePWM EDIS; ] //------------------------------------------------------------- //初始化Epwm1中TripZone的寄存器 //------------------------------------------------------------- void InitTripZone(void) [ EALLOW; EPwm1Regs.TZSEL.bit.OSHT1 = 1; EPwm2Regs.TZSEL.bit.OSHT1 = 1; EPwm3Regs.TZSEL.bit.OSHT1 = 1; EPwm1Regs.TZCTL.bit.TZA = 2; //Pull down EPWM1A When oneshot Trip Event Occure EPwm1Regs.TZCTL.bit.TZB = 2; //Pull down EPWM1B When oneshot Trip Event Occure EPwm2Regs.TZCTL.bit.TZA = 2; //Pull down EPWM2A When oneshot Trip Event Occure EPwm2Regs.TZCTL.bit.TZB = 2; //Pull down EPWM2B When oneshot Trip Event Occure EPwm3Regs.TZCTL.bit.TZA = 2; //Pull down EPWM3A When oneshot Trip Event Occure EPwm3Regs.TZCTL.bit.TZB = 2; //Pull down EPWM3B When oneshot Trip Event Occure EPwm1Regs.TZEINT.bit.OST = 1; //Enable interrupt EPWM1_TZINT EDIS; ] |
|
相关推荐
2个回答
|
|
有没有对外设进行控制的语句在其他的文件中
|
|
|
|
有没有进入低功耗的配置模式的程序
|
|
|
|
只有小组成员才能发言,加入小组>>
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
661 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
587 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1041 浏览 1 评论
720 浏览 0 评论
普中科技F28335开发板每次上电复位后数码管都会显示,如何熄灭它?
516 浏览 1 评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
150浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
115浏览 14评论
在使用3254进行录音的时候出现一个奇怪的现象,右声道有吱吱声,请教一下,是否是什么寄存器设置存在问题?
119浏览 13评论
TLV320芯片内部自带数字滤波功能,请问linein进来的模拟信号是否是先经过ADC的超采样?
117浏览 12评论
TPA6304-Q1: TPA6304 两片公用一组I2C的话,其中一片配置不成功怎么办
159浏览 10评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-19 14:53 , Processed in 0.858081 second(s), Total 82, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号