使用PWM1与PWM2两路ePWM,通过TBPHS调整PWM2与PWM1相位,在调整的过程中,会出现有两个点(CMPA点与CMPB点)出现驱动瞬间断掉的情况,即在EPwm2Regs.TBPHS.half.TBPHS = 745(再将该值减1,就出现下图波形断掉情况),同样在EPwm2Regs.TBPHS.half.TBPHS = 835(再将该值减1,就出现下图波形断掉情况)也一样;请问各位大神,这是那个寄存器配置有问题?
PWM1与PWM2初始化如下:
void InitEPwm1(void)
{
EPwm1Regs.CMPA.half.CMPA = 835;
EPwm1Regs.CMPB = 745;
EPwm1Regs.TBPRD = 1580;
EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm1Regs.TBCTR = 0x0000; // Clear counter
// Setup counter mode
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;//0x0-1分频,TBCLK = SYSCLKOUT / (HSPCLKDIV × CLKDIV)
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Master module
EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; // Sync down-stream module
// Setup shadowing
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_PRD; // Load on Zero
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_PRD;
// Action Qualifier SubModule Registers
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET;//AQ_CLEAR;
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;//AQ_SET;
EPwm1Regs.AQCTLB.bit.CBU = AQ_CLEAR;
EPwm1Regs.AQCTLB.bit.CBD = AQ_SET;
}
void InitEPwm2(void)
{
EPwm2Regs.CMPA.half.CMPA = 835;
EPwm2Regs.CMPB = 745;
EPwm2Regs.TBPRD = 1580;
// Setup TBCLK
EPwm2Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm2Regs.TBCTR = 0x0000; // Clear counter
// Setup counter mode
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;//0x0-1分频,TBCLK = SYSCLKOUT / (HSPCLKDIV × CLKDIV)
EPwm2Regs.TBCTL.bit.PHSEN = TB_ENABLE; // Slave module
EPwm2Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;//TB_SYNC_DISABLE; // sync flow-through
// Setup shadowing
EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_PRD; // Load on Zero
EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_PRD;
// Action Qualifier SubModule Registers
EPwm2Regs.AQCTLA.bit.CAU = AQ_SET;//AQ_CLEAR;
EPwm2Regs.AQCTLA.bit.CAD = AQ_CLEAR;//AQ_SET;
EPwm2Regs.AQCTLB.bit.CBU = AQ_CLEAR;
EPwm2Regs.AQCTLB.bit.CBD = AQ_SET;
}