让EPWM1和EPWM2以相同的频率输出,只是前后相位不同,EPWM1主要设置如下(频率为100Hz)
EPwm1Regs.TBPRD = 18750;
EPwm1Regs.TBPHS.half.TBPHS = 0;
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;
EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm1Regs.TBCTL.bit.SYNCOSEL =TB_CTR_ZERO;
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 2;
EPwm1Regs.TBCTL.bit.CLKDIV = 2;
EPwm1Regs.CMPA.half.CMPA = 12500;
EPwm1Regs.CMPB = 6250;
EPWM2的主要设置如下:
EPwm2Regs.TBPRD = 18750;
EPwm2Regs.TBPHS.half.TBPHS = 12500;
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
EPwm2Regs.TBCTL.bit.PHSEN = TB_ENABLE; //使能PHASE寄存器
EPwm2Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
EPwm2Regs.CMPA.half.CMPA = 12500;
EPwm2Regs.CMPB = 6250;
为什么EPWM2的输出频率是800Hz,为什么不是同频率呢?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
EPwm2Regs.TBCTL.bit.HSPCLKDIV = 2;
EPwm2Regs.TBCTL.bit.CLKDIV = 2;
一周热门 更多>