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.

TMS320F28377S: TMS320f28377 - EPWM11&12 glitch on sync signal with a specific DSP batch

Part Number: TMS320F28377S

Hi,

The following question describes a problem I faced and the investigation that lead me to a workaround. I wish to know if my reasoning is correct and if the workaround will be future proof.

My design uses all 12 EPWM of my DSP. It's configured in 2 groups with one master each that generates a sync signal. PWM1 sync to PWM2 to 6, PWM7 is the master of PWM 8 to 12. All slave has their phase control enabled (PHSEN=1). To get this configuration, SYNCSELEPWM10SYNCIN = 2

I recently started to witness some units failing in a strange pattern whereas the design have been stable for years now. In a random-looking pattern, PWM11 or PWM12 output would make a long pulse. My CPU is running at 200Mhz, TBPRD=1110, working in up-down mode giving a square wave output of 90KHz with a steady 50% duty cycle. Quite often, the output will "skip a pulse" giving one pulse of 150%.

After investigation, I gathered all of these facts

  1. This would only happen on PWM11 & PWM12
  2. Failing pattern only happens in the following conditions (others value tested and behaviour is stable)
    1. Direction is DOWN (PHSDIR=0) and phase value is 0 or 1 (TBPHS=0,1)
    2. Direciton is UP (PHSDIR=1) and phase is 1110 (TBPHS=TBPRD).
  3. The failure is independent of how the CPMA,CMPB, TBPHS register of other PWM module are configured.
  4. All failing units have the same DSP batchcode : YFC-94A9RPW

Pushing the investigation further, I started to monitor the behavior of the counter when the problem occured. What I saw was 2 type of failure mode

1. The up-down mode seemed to miss a CTR=0 or CTR=PRD event and would continue counting out of the bounds [0-1110] until the next sync event.

2. The second failure mode is more troubling.  Upon a sync event, the phase value loaded in the TBCTR register seemed to be random-like. Remember that the counter is supposed to stay within 0 and 1110.

Looking into the manual I found this statement

Conclusion

With all the above statements, I am feeling like there is some kind of race-condition in the timer module. 

Like if the timebase module would invert the counting direction from DOWN to UP when hitting 0, but the sync event would then rechange the direction back to DOWN without having the timebase module reacting a 2nd time and the timer would keep going in the negative (65535 and below). Assuming this would be the case, I can easily saturate my phase register depending on the direction between [2. 1108].

This solutions does fix all the problems, but I cannot explain the 2nd failure mode with that reasoning which leaves me doubtfull about the solution I am using. It would make sense if I was in front of a real hardware asynchronous race-condition, but since I am dealing with a synchronous design, I can't explain the "random-like" phase reload value. But the fact that is tied to a single batch of chip let me think that maybe its an asynchronous race-condition.

I would need the help from TI here to assess what would be the correct approach to deal with this situation.

Thank you very much

  • Hello,

    As we investigate this, could you please change this configuration and see if that get rids of the behavior on EPWM 11/12:

    1. PHSDIR=0 and phase value is 0 
    2. PHSDIR=1 and phase value is 1110

    The EPWM module is not designed to operate under these configurations.

    Best Regards,

    Marlyn

  • Greetings,

    Actually these are the offending conditions detailed in my first post.

    To be more precise, see the following table. 

    This table is for a single unit. It can vary if taken on a different DSP. I've witness a unit having troubles when PHSDIR=1 & TBPHS=0.

    I am confident to say that the problematics conditions are only these:

    • PWM11 or PWM12
    • TBPHS < 2   (PHSDIR=X)
  • Thank you for providing the table. Would it be possible for you to provide some initialization/configuration code so that we may try to replicate the setup?

    Best Regards,

    Marlyn

  • Hi Marlyn,

    It's a bit hard to share a stripped down version of the code. If we can have a private communication channel, I could gladly share some code or even a binary that could be flashed onto a DSP.

    PWMs are configured this way : 

    	pPWMRegs->TBCTL.bit.PRDLD = TB_IMMEDIATE;	
    	pPWMRegs->TBPRD = 1110; 					
    	pPWMRegs->TBCTR = 0;
    
    	pPWMRegs->TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
    	pPWMRegs->TBCTL.bit.HSPCLKDIV = TB_DIV1;
    	pPWMRegs->TBCTL.bit.CLKDIV = TB_DIV1;
    	// Counter Compare Submodule Registers
    	pPWMRegs->CMPA.bit.CMPA = 555;	// set duty 50% initially
    	pPWMRegs->CMPB.bit.CMPB = 555;
    	pPWMRegs->CMPCTL.bit.SHDWAMODE = CC_SHADOW;
    	pPWMRegs->CMPCTL.bit.SHDWBMODE = CC_SHADOW;
    	pPWMRegs->CMPCTL.bit.LOADAMODE = CC_CTR_ZERO_PRD;
    	pPWMRegs->CMPCTL.bit.LOADBMODE = CC_CTR_ZERO_PRD;
    
    	pPWMRegs->AQSFRC.bit.RLDCSF = CC_CTR_ZERO_PRD;
    
    	if(setOnUp == true)
    	{
    		pPWMRegs->AQCTLA.bit.CAD = AQ_CLEAR;
    		pPWMRegs->AQCTLA.bit.CAU = AQ_SET;
    	}
    	else
    	{
    		pPWMRegs->AQCTLA.bit.CAD = AQ_SET;
    		pPWMRegs->AQCTLA.bit.CAU = AQ_CLEAR;
    	}
    
    	pPWMRegs->AQCTLB.bit.CBD = AQ_NO_ACTION;
    	pPWMRegs->AQCTLB.bit.CBU = AQ_NO_ACTION;
    
    	pPWMRegs->DBCTL.bit.IN_MODE = DBA_ALL;
    	pPWMRegs->DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
    	pPWMRegs->DBCTL.bit.POLSEL = DB_ACTV_HIC;
    	pPWMRegs->DBRED.bit.DBRED = 80;
    	pPWMRegs->DBFED.bit.DBFED = 80;

    setOnUp is true for PWM 2,4,6,8,10,12 and false for PWM 1,3,5,7,9,11

    Masters are set like this

    EPwm1Regs.TBCTL.bit.PHSEN = 1;
    EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
    EPwm7Regs.TBCTL.bit.PHSEN = 1;
    EPwm7Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;

    Slaves are set like this.

    EPwm2Regs.TBCTL.bit.PHSEN = 1;
    EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
    EPwm2Regs.TBPHS.bit.TBPHS = 0;
    
    EPwm3Regs.TBCTL.bit.PHSEN = 1;
    EPwm3Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
    EPwm3Regs.TBPHS.bit.TBPHS = 0;
    
    /*
    Repeat for PWM 2,3,4,5,6, 8,9,10,11,12
    */

    Regards

  • Hi,

    Thank you for sharing the configuration. I'll try to replicate this on my side as soon as possible and keep you updated. 

    Best Regards,

    Marlyn

  • Thank you Marlyn,

    Should we consider sending you some faulty DSP? As I said, the issue appears only on some units.

    Regards

  • Hi

    I wanted to publicly share the answer that you provided offline. Thank you again for the support and the high level of expertise.

    So it looks like we are running our DSP out of specifications.

    1. There is a chain of 5 PWM and there is a limit of 4 (refering to section 13.4.3.3 of the user manual). The problematic chain is PWM1,7,10,11,12.  I can fix this issue by using EPWM7SYNCIN = 3, which generates the same behavior.

    2. The clock ferquency of 200MHz is not right. The EPWM module inside the TMS320f28377 has a maximum frequnecy of 100MHz as per the device datasheet  (section 7.9.3.2.2.1 - Internal clock frequencies).  Therefore,  EPWMCLKDIV shall be set to 1 instead of 0.

    I will mark this as the answer as soon as I will have the chance to test the correction on few units.

    Regards