EPWM1的初始化程序中已经初始化TZ代码如下:
EALLOW;
EPwm1Regs.TZCTL.bit.TZA = TZ_NO_CHANGE; //EPwm1A output is not changed
EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_LO; //Force EPWMxB to a low state
EPwm1Regs.TZEINT.bit.OST = 1; //Enable OST Interrupt
EDIS;
并在AD中断中让计数寄存器Count1累加,代码如下
Count1++;
if(Count1 == 3000)
{
Count1 = 0;
}
if(Count1 >= 2000 && Count1 < 3000)
{
EALLOW;
EPwm1Regs.TZFRC.bit.OST = 1;
EDIS;
}
else
{
EALLOW;
EPwm1Regs.TZFRC.bit.OST = 0;
EPwm1Regs.TZCLR.bit.OST = 1;
EPwm1Regs.TZCLR.bit.INT = 1;
EDIS;
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>