寄存器配置 比较器1H 事件配置为TRIP4,TRIP4 映射 DCAEVT2 ,DCAEVT2 使能逐周期封波 PWM1A 。 目前可以产生DCAEVT2事件,无法逐周期封波ePWM1A ? 现在不清楚比较器触发的TRIPx事件,怎么配置为CBC源,实现有效的逐周期封波功能。 //Configure TRIP4
EALLOW;
EPwmXbarRegs.TRIP4MUX0TO15CFG.bit.MUX0 = 0;//PV电流保护信号
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;
EDIS; EALLOW;
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
//EPWM1INTI
EPwm1Regs.TBPRD = cSwitchFreqPrd; // 设置PWM1周期,及可以设定其中断频率
EPwm1Regs.TBPHS.bit.TBPHS = 0x0000;//相位偏移寄存器,发生同步事件时,时基计数器(TBCTR)将加载相位(TBPHS)
EPwm1Regs.TBCTR = 0x0000;//时基计数器(TBCTR)
EPwm1Regs.TBCTL.bit.CTRMODE = 0x2; //2增减计数模式
EPwm1Regs.TBCTL.bit.PHSEN = 0x0; //1使能相位偏移同步
EPwm1Regs.TBCTL.bit.PRDLD = 0x0; //如果 TBCTL PRDLD=0,则影子被启用,任何写入或读取都将自动进入影子寄存器。在这种情况下,当时基计数器等于零时,将从影子 寄存器加载活动寄存器。 EPwm1Regs.EPWMSYNCINSEL.bit.SEL = 0;//同步信号源0:Disabled;
EPwm1Regs.EPWMSYNCOUTEN.bit.ZEROEN = 1;//TBCTR==0时触发输出同步信号 EPWM1.SYNCOUT
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0x0; //时基时钟预分频位 TBCLK=SYSCLKOUT/(HSPCLKDIV*CLKDIV)
EPwm1Regs.TBCTL.bit.CLKDIV = 0x0; //高速时基时钟预分频位 CLKDIV = 1;HSPCLKDIV = 2;
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0x0; //计数器比较 A(CMPA)寄存器工作模式
EPwm1Regs.CMPCTL.bit.SHDWBMODE = 0x0;
EPwm1Regs.CMPCTL.bit.LOADAMODE = 0x0;//活动计数器比较 A(CMPA)从影子选择模式加载 ;10:CTR = 0 或 CTR = PRD 时加载
EPwm1Regs.CMPCTL.bit.LOADBMODE = 0x0;//
EPwm1Regs.AQCTLA.bit.CAU = 0x1; //L
EPwm1Regs.AQCTLA.bit.CAD = 0x2; //H
EPwm1Regs.AQCTLB.bit.CBU = 0x1; //
EPwm1Regs.AQCTLB.bit.CBD = 0x2; //
// 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;数字比较输出 B 事件 2 选择;DCBH=高,DCBL=不关心
EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 0xF;//跳闸组合输入(由 DCAHTRIPSEL 寄存器选择的所有跳闸输入一起或运算)
EPwm1Regs.DCAHTRIPSEL.bit.TRIPINPUT4 = 1;// 1 enable int comp 跳闸输入
EPwm1Regs.DCAHTRIPSEL.bit.TRIPINPUT9 = 1;// 1 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 TRIP9
EPwm1Regs.TZDCSEL.bit.DCBEVT2 = 0x02;//高封波,配合比较器输出的高低使用;封Pwm1B;
EPwm1Regs.DCTRIPSEL.bit.DCBHCOMPSEL = 0xF;//跳闸组合输入(由 DCBHTRIPSEL 寄存器选择的所有跳闸输入一起或运算)
//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; //OK TZ1 至 TZ6、DCAEVT1/2、DCBEVT1/2 EPWMxB 跳闸后 2强制 EPWMxA 处于低状态
EPwm1Regs.TZCTL.bit.TZB = 0x02; //OK 强制 EPWMxB 进入低状态
EPwm1Regs.TZCLR.bit.DCAEVT2 = 1; //清除 DCAEVT2 事件跳闸条件 add
EPwm1Regs.TZCLR.bit.DCBEVT2 = 1; //清除 DCBEVT2 事件跳闸条件 add
EPwm1Regs.TZSEL.bit.OSHT1 = 1;//启用 TZ1 作为该 ePWM 模块的一次性跳闸源
EPwm1Regs.TZCLR.bit.OST = 1;//一次性跳闸(OST)闩锁的清除标志
EPwm1Regs.TZOSTCLR.bit.OST1 = 1; //Oneshot(OST1)跳闸闩锁的清除标志
EPwm1Regs.ETSEL.bit.INTSEL = 0x1; //1:时基计数器等于 0 时启用事件。(TBCTR = 0x00)
EPwm1Regs.ETSEL.bit.INTEN = 0; //禁用ePWM 中断(EPWMx_INT)生成
EPwm1Regs.ETPS.bit.INTPRD = 1; //01:在第一个事件 INTCNT=01(第一个事件)上生成中断
EPwm1Regs.ETCLR.bit.INT = 1; //清除 ET**[INT]标志位,并允许生成更多中断脉冲 EPwm1Regs.ETSEL.bit.SOCAEN = 1;// Enable SOC on A group 启用 ADC 启动转换 A(EPWMxSOCA)脉冲
EPwm1Regs.ETSEL.bit.SOCASEL = 2;//3 时基计数器等于零或周期时启用事件(TBCTR=0x00 或 TBCTR=TBPRD) 20221114 改为20KHZ 50us ADC ePWM触发源减半,频率自然减半
EPwm1Regs.ETPS.bit.SOCAPRD = 1;//在第?个事件上生成 EPWMxSOCA 脉冲 EPwm1Regs.ETSEL.bit.SOCBEN = 1; // Enable SOC on B group 启用 ADC 启动转换 B(EPWMxSOCB)脉冲
EPwm1Regs.ETSEL.bit.SOCBSEL = 1; // 在PWM0点的时候进行AD转化
EPwm1Regs.ETPS.bit.SOCBPRD = 1; // Generate pulse on 1st event EDIS;
EALLOW;
|