完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
希望28335中6个EPWM同步:我在主程序main中编写以下程序:
SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 0; // ePWM1-ePWM6 使能(请问这里是设置成0还是1?) SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 0; SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 0; SysCtrlRegs.PCLKCR1.bit.EPWM4ENCLK = 0; SysCtrlRegs.PCLKCR1.bit.EPWM5ENCLK = 0; SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 0; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; EPWM1init();//对ePWM1-ePWM6 寄存器进行配置 EPWM2init(); EPWM3init(); EPWM4init(); EPWM5init(); EPWM6init(); SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; 请问上述程序能不能实现EPWM模块的同步,对不对? 谢谢! |
|
相关推荐
3 个讨论
|
|
您好!
需要置1. SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1; // ePWM1 SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 1; // ePWM2 SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 1; // ePWM3 SysCtrlRegs.PCLKCR1.bit.EPWM4ENCLK = 1; // ePWM4 SysCtrlRegs.PCLKCR1.bit.EPWM5ENCLK = 1; // ePWM5 SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 1; // ePWM6 如果要实现内部同步的话,可以参考以下代码中的几句话,另外以下代码是从ePWM用户指南中81页中摘录出来的,http://www.ti.com/lit/ug/sprug04a/sprug04a.pdf //===================================================================== // Configuration //===================================================================== // Initialization Time //========================// EPWM Module 1 config EPwm1Regs.TBPRD = 800; // Period = 1600 TBCLK counts EPwm1Regs.TBPHS.half.TBPHS = 0; // Set Phase register to zero EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Symmetrical mode EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Master module EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW; EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; // Sync down-stream module EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW; EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // set actions for EPWM1A EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR; EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // enable Dead-band module EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active Hi complementary EPwm1Regs.DBFED = 50; // FED = 50 TBCLKs EPwm1Regs.DBRED = 50; // RED = 50 TBCLKs // EPWM Module 2 config EPwm2Regs.TBPRD = 800; // Period = 1600 TBCLK counts EPwm2Regs.TBPHS.half.TBPHS = 0; // Set Phase register to zero EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Symmetrical mode EPwm2Regs.TBCTL.bit.PHSEN = TB_ENABLE; // Slave module EPwm2Regs.TBCTL.bit.PRDLD = TB_SHADOW; EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN; // sync flow-through EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW; EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero EPwm2Regs.AQCTLA.bit.CAU = AQ_SET; // set actions for EPWM2A EPwm2Regs.AQCTLA.bit.CAD = AQ_CLEAR; EPwm2Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // enable Dead-band module EPwm2Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active Hi complementary EPwm2Regs.DBFED = 50; // FED = 50 TBCLKs EPwm2Regs.DBRED = 50; // RED = 50 TBCLKs // EPWM Module 3 config EPwm3Regs.TBPRD = 800; // Period = 1600 TBCLK counts EPwm3Regs.TBPHS.half.TBPHS = 0; // Set Phase register to zero EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Symmetrical mode EPwm3Regs.TBCTL.bit.PHSEN = TB_ENABLE; // Slave module EPwm3Regs.TBCTL.bit.PRDLD = TB_SHADOW; EPwm3Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN; // sync flow-through EPwm3Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; EPwm3Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW; EPwm3Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero EPwm3Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero EPwm3Regs.AQCTLA.bit.CAU = AQ_SET; // set actions for EPWM3A EPwm3Regs.AQCTLA.bit.CAD = AQ_CLEAR; EPwm3Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // enable Dead-band module EPwm3Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active Hi complementary EPwm3Regs.DBFED = 50; // FED = 50 TBCLKs EPwm3Regs.DBRED = 50; // RED = 50 TBCLKs // Run Time (Note: Example execution of one run-time instant) //========================================================= EPwm1Regs.CMPA.half.CMPA = 500; // adjust duty for output EPWM1A EPwm2Regs.CMPA.half.CMPA = 600; // adjust duty for output EPWM2A EPwm3Regs.CMPA.half.CMPA = 700; // adjust duty for output EPWM3A Young Hu C2000 FAE |
|
|
|
|
|
实验程序如下:
void main(void) [ DeviceInit(); // Device Life support & GPIO // Configure PWM1AB PWM_ComplPairDB_CNF(1, 400, 1, 0); // Configure PWM4 PWM_1ch_CNF(4, 400, 1, 0); SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; for(;;); ] 我在DeviceInit() 函数中定义了EPWM的时钟: SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1; // ePWM1 SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 1; // ePWM2 SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 1; // ePWM3 SysCtrlRegs.PCLKCR1.bit.EPWM4ENCLK = 1; // ePWM4 SysCtrlRegs.PCLKCR1.bit.EPWM5ENCLK = 0; // ePWM5 SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 0; // ePWM6 SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; // Enable TBCLK within the ePWM 在main 函数中 初始化设置了EPWM1 和EPWM4: 最后使能了SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; 为什么非但不能使两个EPWM同步,连波形都产生不了,这是为什么? 另注:当DeviceInit() 中设置成: SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1; // ePWM1 SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 1; // ePWM2 SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 1; // ePWM3 SysCtrlRegs.PCLKCR1.bit.EPWM4ENCLK = 1; // ePWM4 SysCtrlRegs.PCLKCR1.bit.EPWM5ENCLK = 0; // ePWM5 SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 0; // ePWM6 SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // Enable TBCLK within the ePWM 且main函数: void main(void) [ DeviceInit(); // Device Life support & GPIO // Configure PWM1AB PWM_ComplPairDB_CNF(1, 400, 1, 0); // Configure PWM4 PWM_1ch_CNF(4, 400, 1, 0); for(;;); ] 此时是有波形的,也就是强调了,EPWM的寄存器设置是没有问题的。 谢谢解答! |
|
|
|
|
|
只有小组成员才能发言,加入小组>>
358 浏览 1 评论
551 浏览 2 评论
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
797 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
667 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1142 浏览 1 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
95浏览 29评论
386浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
268浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
218浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
75浏览 13评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-31 06:07 , Processed in 0.801156 second(s), Total 48, Slave 42 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号