This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28377D: # ePWM

Part Number: TMS320F28377D


Tool/software: Code Composer Studio

HI everyone,

       I  use 28377D to generate the PWM waves,and each phase has 4 pwms。EPWM1 is the master and EPWM2~EPWM6 are slave. Phase A uses EPWM1 and EPWM2, Phase B uses EPWM3 and EPWM4.Phase C uses EPWM4 and EPWM5.      

       The phenomenon is very odd,Phase B and Phase C  can generate normal waves,but the wave which is generated  from phase A has some large overshoot,The overshoot don't  often appear and it  will be consecutively when it appears.

        So i doubt that it relate with EPWM1 and EPWM2。Perhaps some registers don't be configured properly.

My register configuration is following.

Initial part:


void PWMchUpDwnCntConfig(int16 n,int16 mode, int16 phase)
{

(*ePWM[n]).TBCTL.bit.HSPCLKDIV = 1;
(*ePWM[n]).TBCTL.bit.CLKDIV = 1;
(*ePWM[n]).TBCTL.bit.PRDLD = TB_SHADOW;
(*ePWM[n]).TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
(*ePWM[n]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
(*ePWM[n]).TBCTL.bit.CLKDIV = TB_DIV1;

if (mode == 1) // config as a Master
{
(*ePWM[n]).TBCTL.bit.PHSEN = TB_DISABLE;
(*ePWM[n]).TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
}
else if (mode == 0) // config as a Slave
{
(*ePWM[n]).TBCTL.bit.PHSEN = TB_ENABLE;
(*ePWM[n]).TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
(*ePWM[n]).TBCTL.bit.PHSDIR = TB_UP;
}

if(n % 2 == 0)
{
(*ePWM[n]).TBCTR = 0;
(*ePWM[n]).TBPHS.bit.TBPHS = 0;
(*ePWM[n]).TBPRD = 3200;
(*ePWM[n]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
(*ePWM[n]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;
(*ePWM[n]).CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
(*ePWM[n]).CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
}
else
{
(*ePWM[n]).TBCTR = 0;
(*ePWM[n]).TBPHS.bit.TBPHS = 3200;
(*ePWM[n]).TBPRD = 6400;
(*ePWM[n]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
(*ePWM[n]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;
(*ePWM[n]).CMPCTL.bit.LOADAMODE = CC_CTR_PRD;
(*ePWM[n]).CMPCTL.bit.LOADBMODE = CC_CTR_PRD;
}

(*ePWM[n]).CMPA.bit.CMPA = 0;

(*ePWM[n]).AQCTLA.bit.CAU = AQ_CLEAR;
(*ePWM[n]).AQCTLA.bit.CAD = AQ_SET;
(*ePWM[n]).AQCTLA.bit.CBU = AQ_NO_ACTION;
(*ePWM[n]).AQCTLA.bit.CBD = AQ_NO_ACTION;
(*ePWM[n]).AQCTLA.bit.PRD = AQ_NO_ACTION;
(*ePWM[n]).AQCTLA.bit.ZRO = AQ_NO_ACTION;

(*ePWM[n]).AQCTLB.bit.CAU = AQ_CLEAR;
(*ePWM[n]).AQCTLB.bit.CAD = AQ_SET;
(*ePWM[n]).AQCTLB.bit.CBU = AQ_NO_ACTION;
(*ePWM[n]).AQCTLB.bit.CBD = AQ_NO_ACTION;
(*ePWM[n]).AQCTLB.bit.PRD = AQ_NO_ACTION;
(*ePWM[n]).AQCTLB.bit.ZRO = AQ_NO_ACTION;

(*ePWM[n]).DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
(*ePWM[n]).DBCTL.bit.POLSEL = DB_ACTV_HIC;
(*ePWM[n]).DBCTL.bit.IN_MODE = DBA_RED_DBB_FED;
(*ePWM[n]).DBRED.bit.DBRED = DB_RISING_EDGE_DELAY;
(*ePWM[n]).DBFED.bit.DBFED = DB_FALLING_EDGE_DELAY;
}

PWMchUpDwnCntConfig(0,1,0);//EPWM1 is master
PWMchUpDwnCntConfig(1,0,0);
PWMchUpDwnCntConfig(2,0,0);
PWMchUpDwnCntConfig(3,0,0);
PWMchUpDwnCntConfig(4,0,0);
PWMchUpDwnCntConfig(5,0,0);

when the timer interrupt  appears,EPWM(1~6) will update the CMPA.

Can you give some advices?Thank you!

  • Hi Zhuqing,

    A large overshoot for a couple periods might indicate that you are writing a compare value larger than TBPRD. It looks like you have 2 different period values, are you sure you never write a compare value that is too large?
  • Every phase has two EPWM,one TBCTR scope is between 0 and 3200 and the other is between 3200 and 6400,  the COMPA between 0 and 6400( EPWM has the some COMPA value).Phase B and C have no problem but phase A has something wrong which has overshoot .

    I doubt that something wrong in EPWM1 which is the master,it syncs with other EPWM module when its CTR is ZERO. So whether my EPWM1 register configuration is wrong or not?

    Somewhere ,the COMPA is the larger than  EPWM1(PWM is high level in this moment) and also somewhere the COMPA is less than EPWM2(PWM is low level in this moment) .This strategy exists in  between EPWM3 and EPWM4(phase B),between EPWM5 and EPWM6(phase C).

    the moment which loads COMPA is different between EPWM1(CTR equals to zero) and EPWM2(CTR equals to period),I also tryed  to set the COMPA at the same load moment,but something defect appeared on the output wave.