comp1H电流过流保护产生TRIP4,如何配置ePWM1A实现逐周期封波? 以下为寄存器配置,还望给与指点迷津,谢谢
EALLOW;
EPwmXbarRegs.TRIP4MUX0TO15CFG.bit.MUX0 = 0;//电流保护信号
EPwmXbarRegs.TRIP4MUXENABLE.bit.MUX0 = 1; //comp1H
EPwmXbarRegs.TRIP9MUX0TO15CFG.bit.MUX6 = 0;//过压保护信号
EPwmXbarRegs.TRIP9MUXENABLE.bit.MUX6 = 1; //comp4H
EPwmXbarRegs.TRIP10MUX0TO15CFG.bit.MUX9 = 1;//INPUTXBAR5
EPwmXbarRegs.TRIP10MUXENABLE.bit.MUX9 = 0;
EPwmXbarRegs.TRIP11MUX0TO15CFG.bit.MUX11 = 1;//INPUTXBAR6
EPwmXbarRegs.TRIP11MUXENABLE.bit.MUX11 = 0;
EDIS;
EALLOW;
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
//EPWM1INTI
EPwm1Regs.TBPRD = cSwitchFreqPrd; //PWM1周期
EPwm1Regs.TBPHS.bit.TBPHS = 0x0000;
EPwm1Regs.TBCTR = 0x0000;//时基计数器(TBCTR)
EPwm1Regs.TBCTL.bit.CTRMODE = 0x2; //2增减计数模式
EPwm1Regs.TBCTL.bit.PHSEN = 0x0; //1使能相位偏移同步
EPwm1Regs.TBCTL.bit.PRDLD = 0x0;
EPwm1Regs.EPWMSYNCINSEL.bit.SEL = 0;//同步信号源0:Disabled;
EPwm1Regs.EPWMSYNCOUTEN.bit.ZEROEN = 1;//TBCTR==0时触发输出同步信号 EPWM1.SYNCOUT
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0x0;
EPwm1Regs.TBCTL.bit.CLKDIV = 0x0;
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0x0;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = 0x0;
EPwm1Regs.CMPCTL.bit.LOADAMODE = 0x0;
EPwm1Regs.CMPCTL.bit.LOADBMODE = 0x0;//
EPwm1Regs.AQCTLA.bit.CAU = 0x1; //L PWM1A on up = CMPA
EPwm1Regs.AQCTLA.bit.CAD = 0x2; //H PWM1A on down = CMPA
EPwm1Regs.AQCTLB.bit.CBU = 0x1; // set PWM1B on up = CMPB
EPwm1Regs.AQCTLB.bit.CBD = 0x2; // clr PWM1B on down = CMPB
// Setup compare
EPwm1Regs.CMPA.bit.CMPA = 0;
EPwm1Regs.CMPA.bit.CMPAHR = 0;
EPwm1Regs.CMPB.bit.CMPB = 0;
EPwm1Regs.CMPB.bit.CMPBHR = 0;
EPwm1Regs.AQSFRC.bit.RLDCSF = 3;
EPwm1Regs.AQCSFRC.bit.CSFA = 0x1;
EPwm1Regs.AQCSFRC.bit.CSFB = 0x1;
//Configure DCA to be TRIP4 TRIP9 TRIP10 TRIP11
EPwm1Regs.TZDCSEL.bit.DCAEVT2 = 0x02;//高封波,配合比较器输出的高低使用;封Pwm1A
EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 0xF;//跳闸组合输入(所有跳闸输入一起或运算)
EPwm1Regs.DCAHTRIPSEL.bit.TRIPINPUT4 = 1;//I enable int comp 跳闸输入
EPwm1Regs.DCAHTRIPSEL.bit.TRIPINPUT9 = 1;//V enable int comp
EPwm1Regs.DCAHTRIPSEL.bit.TRIPINPUT10 = 0;
EPwm1Regs.DCAHTRIPSEL.bit.TRIPINPUT11 = 0;
EPwm1Regs.DCACTL.bit.EVT2SRCSEL = 0; //0:输入源为 DCAEVT2 信号
EPwm1Regs.DCACTL.bit.EVT2FRCSYNCSEL = 1; //1:输入源与 EPWMCLK 同步
//Configure DCB to be TRIP8 TRIP9
EPwm1Regs.TZDCSEL.bit.DCBEVT2 = 0x02;//高封波,配合比较器输出的高低使用;封Pwm1B;
EPwm1Regs.DCTRIPSEL.bit.DCBHCOMPSEL = 0xF;//跳闸组合输入(所有跳闸输入一起或运算)
EPwm1Regs.DCBHTRIPSEL.bit.TRIPINPUT8 = 1;//I2/6 1 enable int comp
EPwm1Regs.DCBHTRIPSEL.bit.TRIPINPUT9 = 1;//Vbus 1 enable int comp
EPwm1Regs.DCBHTRIPSEL.bit.TRIPINPUT10 = 0;
EPwm1Regs.DCBHTRIPSEL.bit.TRIPINPUT11 = 0;
EPwm1Regs.DCBCTL.bit.EVT2SRCSEL = 0; //0:输入源为 DCBEVT2 信号
EPwm1Regs.DCBCTL.bit.EVT2FRCSYNCSEL = 1; //1:输入源与 EPWMCLK 同步
EPwm1Regs.TZCTL.bit.DCAEVT2 = 0X02;//强制 EPWMxA 处于低状态。
EPwm1Regs.TZCTL.bit.DCBEVT2 = 0X02;//10:强制 EPWMxB 处于低状态。
EPwm1Regs.TZCTL.bit.TZA = 0X02; //强制 EPWMxA 处于低状态
EPwm1Regs.TZCTL.bit.TZB = 0x02; //强制 EPWMxB 进入低状态
EPwm1Regs.TZCLR.bit.DCAEVT2 = 1; //清除 DCAEVT2 事件跳闸条件
EPwm1Regs.TZCLR.bit.DCBEVT2 = 1; //清除 DCBEVT2 事件跳闸条件
EPwm1Regs.TZSEL.bit.DCAEVT2 = 1;//启用 DCABEVT2 作为该 ePWM 模块的 CBC 跳闸源
EPwm1Regs.TZCBCCLR.bit.DCAEVT2 = 1; //为 CBC 选择的数字比较输出 A 事件 2 清除标志
EPwm1Regs.TZSEL.bit.DCBEVT2 = 1;
EPwm1Regs.TZCBCCLR.bit.DCBEVT2 = 1; //为 CBC 选择的数字比较输出 B 事件 2 清除标志
EPwm1Regs.TZCLR.bit.CBCPULSE = 0; //CTR=0 脉冲清除 CBC 跳闸锁存器
EPwm1Regs.TZCLR.bit.CBC = 1; //no 逐周期循环(CBC)跳闸闩锁的清除标志 |