我是按照Ti中的epwm_trip_zone的例程设置的寄存器的,但是现在程序也能按照我的想法当满足条件时,软件触发中断后,指定的epwm1A强制输出低电平,不满足条件时,按原来情况输出。但是,我现在就是不能计算出多长时间进入一次epwm trip zone的中断?请各位高手指点,谢谢,设置代码如下:
1.在epwm初始化中设置如下:
EALLOW;
EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO; // Do nothing,no action is taken on EPWMxA
EPwm1Regs.TZCTL.bit.TZB = TZ_NO_CHANGE; // Force EPWMxB to a low state
EPwm1Regs.TZEINT.bit.OST = 1; // Enable OST interrupt
EDIS;
2.满足条件时,设置强制触发
if(Current>= 50)
{
EALLOW;
EPwm2Regs.TZFRC.bit.OST = 1;
EDIS;
}
else
{
}
3.epwm trip zone的中断函数
interrupt void EPWM1_TZint_ISR(void)
{
EALLOW;
EPwm1Regs.TZFRC.bit.OST = 0;
EPwm1Regs.TZCLR.bit.OST = 1;
EPwm1Regs.TZCLR.bit.INT = 1;
EDIS;
// Acknowledge this interrupt to receive more interrupts from group 2
PieCtrlRegs.PIEACK.all = PIEACK_GROUP2;
}
|