首先不好意思,我没有TI的这个芯片,但是对于ePWM这一块移植到其他平台上时,因为仿真的结果有问题,需要了解下这个波形的样式。
void InitEPwm1(void)
{
InitEPwm1Gpio();
EPwm1Regs.TBPRD = 7500; //周期 3750*1/150000000=1/20000
EPwm1Regs.CMPA.half.CMPA = 0; //A占空比
//EPwm1Regs.CMPB = 4000; //B占空比
/*时基模块寄存器*/
EPwm1Regs.TBPHS.all = 0;
EPwm1Regs.TBCTR = 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_SYNC_DISABLE;
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
/*计数比较模块寄存器*/
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; //影子寄存器A在CTR_ZERO时装载
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; //影子寄存器B在CTR_ZERO时装载
/*死区产生模块寄存器*/
EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; //死区模块使能
EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; //极性选择控制
EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL; //A。B输出控制
EPwm1Regs.DBRED = 100; //延时计数器 0~1023
EPwm1Regs.DBFED = 100; //延时计数器 0~1023
/*动作模块寄存器*/
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; //时基计数器值与CMPA寄存器值比较
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;
/*事件触发模块寄存器*/
EPwm1Regs.ETSEL.bit.SOCAEN = 1; //使能ePWM1SOCB信号产生位
EPwm1Regs.ETSEL.bit.SOCASEL = ET_CTR_ZERO; //ePWM1SOCB信号产生条件:当TBCTR=0时
EPwm1Regs.ETPS.bit.SOCAPRD = ET_1ST; //在第一个事件时,产生SOC信号
EPwm1Regs.ETSEL.bit.INTEN = 1; //使能ePWM中断产生位
EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; //中断选择条件
EPwm1Regs.ETPS.bit.INTPRD = ET_1ST; //中断产生条件
}
后续如果我输出
EPwm1Regs.CMPA.half.CMPA = 0; (1)
EPwm1Regs.CMPA.half.CMPA = 750; (2)
对于上述的(1)PWM输出的是上桥臂0%,下桥臂100%占空比
(2)PWM输出的是上桥臂10%,下桥臂90%占空比 么?
烦请大神帮忙看下。
谢谢。
|