TI论坛
直播中

刘玉华

7年用户 165经验值
私信 关注
[问答]

F28377D EPWM中断周期计算与实测差了一倍

以下是epwm的设置,按主频200M来计算,EPWM3B输出频率应该是50K,可是实际测出来是25K,是我设置问题还是理解出了问题,希望工程师能帮忙解决下
void InitEPwm3Example(void)
[
// Setup TBCLK
EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
EPwm3Regs.TBPRD = EPWM3_tiMER_TBPRD; // Set timer period
EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm3Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
EPwm3Regs.TBCTR = 0x0000; // Clear counter
EPwm3Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT,0x00
EPwm3Regs.TBCTL.bit.CLKDIV = TB_DIV1;
// Setup shadow register load on ZERO
EPwm3Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm3Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm3Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
EPwm3Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
// Set Compare values
EPwm3Regs.CMPA.bit.CMPA = EPWM3_MIN_CMPA; // Set compare A value
EPwm3Regs.CMPB.bit.CMPB = EPWM3_MAX_CMPB; // Set Compare B value
// Set Actions
EPwm3Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM3A on event B, up count
EPwm3Regs.AQCTLA.bit.CBU = AQ_CLEAR; // Clear PWM3A on event B, up count
EPwm3Regs.AQCTLB.bit.ZRO = AQ_TOGGLE; // Toggle EPWM3B on Zero
// Interrupt where we will change the Compare Values
EPwm3Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
EPwm3Regs.ETSEL.bit.INTEN = 1; // Enable INT
EPwm3Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
]

回帖(4)

刘玉华

2018-9-14 11:51:43
EPWM3_TIMER_TBPRD=2000
举报

刘玉华

2018-9-14 12:05:32
引用: boxi13058485785 发表于 2018-9-14 15:21
EPWM3_TIMER_TBPRD=2000

找到了,加一句话就好了。之前没仔细阅读文档,打搅了
ClkCfgRegs.PERCLKDIVSEL.bit.EPWMCLKDIV=0x0;
举报

冯敬宇

2018-9-14 12:22:21
引用: boxi13058485785 发表于 2018-9-14 15:35
找到了,加一句话就好了。之前没仔细阅读文档,打搅了
ClkCfgRegs.PERCLKDIVSEL.bit.EPWMCLKDIV=0x0;

找到了,加一句话就好了。之前没仔细阅读文档,打搅了
ClkCfgRegs.PERCLKDIVSEL.bit.EPWMCLKDIV=0x0;
ERIC:
不能这样设置,EPWM最大的时钟是100MHz.
                                                                         - ERIC
举报

刘玉华

2018-9-14 12:35:57
引用: guigui_7044 发表于 2018-9-14 15:52
找到了,加一句话就好了。之前没仔细阅读文档,打搅了
ClkCfgRegs.PERCLKDIVSEL.bit.EPWMCLKDIV=0x0;
ERIC:

谢谢,我给改回来了,初学dsp,有没有好的文档推荐,找资料也不容易啊这,,谢谢啦
举报

更多回帖

发帖
×
20
完善资料,
赚取积分