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.

TMS320F28377D: Use high resolution period and high resolution duty cycle simultaneously will cause Jitter on ePWM out

Part Number: TMS320F28377D
Other Parts Discussed in Thread: CONTROLSUITE

Hi Champs,

In my customer's application, high resolution period and high resolution duty cycle will be used simultaneously. And they found there were some jitter on the ePWMxA's output.

You can see the scope capture as follows. The yellow waveform is ePWM1A output, and the blue one is ePWM3A output.

And also, if EPwm1Regs.HRPCTL.bit.HRPE was set to zero, the jitter will be gone. 

So the question is whether high resolution period and high resolution duty cycle can be used simultaneously? 

Thanks.

Regards,

Young

  • According to this:

    HRPWM for for hi-res duty and period control in up-down count (symmetric) mode - C2000 microcontrollers...

    e2e.ti.com
    Other Parts Discussed in Thread: CONTROLSUITE Engineer Question: What is the proper way to configure the HRPWM for hi-res duty and period control in up-down count

    It is possible but you must follow this:

    // Disable TBCLKSYNC
        EALLOW;
                SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;     
        EDIS;
     
    //Write To CMP, TBPRD, TBPHS registers.
        (*ePWM[j]).TBCTL.bit.PRDLD = TB_SHADOW;             // set Shadow load
        (*ePWM[j]).TBPRD = period;                                         // PWM frequency = 1/(2*TBPRD)
        (*ePWM[j]).CMPA.half.CMPA = period / 2;                   // set duty 50% initially
        (*ePWM[j]).CMPA.half.CMPAHR = (0 << 8);                 // initialize HRPWM extension
        (*ePWM[j]).TBPHS.all = 0;
     
    //Configure modes, clock dividers and action qualifier
        (*ePWM[j]).TBCTR = 0;
        (*ePWM[j]).TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;     // Select up-down count mode
        (*ePWM[j]).TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;      
        (*ePWM[j]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
        (*ePWM[j]).TBCTL.bit.CLKDIV = TB_DIV1;                             // TBCLK = SYSCLKOUT
        (*ePWM[j]).TBCTL.bit.FREE_SOFT = 00;
     
        (*ePWM[j]).CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;      // LOAD CMPA on CTR = 0
        (*ePWM[j]).CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;        
        (*ePWM[j]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
        (*ePWM[j]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;
     
        (*ePWM[j]).AQCTLA.bit.CAU = AQ_SET;                 
        (*ePWM[j]).AQCTLA.bit.CAD = AQ_CLEAR;
        (*ePWM[j]).AQCTLB.bit.ZRO = AQ_SET
        (*ePWM[j]).AQCTLB.bit.PRD = AQ_CLEAR;
       
    //Configure HRPWM registers
        EALLOW;
         (*ePWM[j]).HRCNFG.all = 0x0;
         (*ePWM[j]).HRCNFG.bit.EDGMODE = HR_BEP;                      // MEP control on both edges
         (*ePWM[j]).HRCNFG.bit.CTLMODE = HR_CMP;                      // CMPAHR and TBPRDHR HR control
         (*ePWM[j]).HRCNFG.bit.HRLOAD  = HR_CTR_ZERO_PRD;    // load on CTR = 0 and CTR = TBPRD
         (*ePWM[j]).HRCNFG.bit.AUTOCONV = 1;                               // Enable autoconversion
         (*ePWM[j]).HRPCTL.bit.HRPE = 1;                                         // Turn on high-resolution period control
     
    //set TBCTL[PHSEN] = 1
         (*ePWM[j]).TBCTL.bit.PHSEN = 1;
     
    //set HRPCTL[TBPHSHRLOADE] = 1
         (*ePWM[j]).HRPCTL.bit.TBPHSHRLOADE = 1;
        
    //Do the same to all other PWM modules
    …
     
    //Enable TBCLKSYNC
         SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;                         
     
    //Perform a software sync 
         EPwm1Regs.TBCTL.bit.SWFSYNC = 1;                

  • Hi Nima,

    Customer revise the code accordingly, but the issue still exists. Would you kindly help to review the code as follows?

    void HRPWM_TG_Config(period)

    {
        Uint16 j;
        //
        // ePWM channel register configuration with HRPWM
        // ePWMxA toggle low/high with MEP control on Rising edge
        //
        // Disable TBCLKSYNC
    	EALLOW;
    	CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    	EDIS;
    
        for(j=1; j<PWM_CH; j++)
        {
    		//Write To CMP, TBPRD, TBPHS registers.
    		(*ePWM[j]).TBCTL.bit.PRDLD = TB_SHADOW;             // set Shadow load
    		(*ePWM[j]).TBPRD = period;                                         // PWM frequency = 1/(2*TBPRD)
            (*ePWM[j]).TBPRDHR = (1 << 8);               // PWM frequency = 1/(2*TBPRD)
    		(*ePWM[j]).CMPA.bit.CMPA = period/2;                   // set duty 50% initially
    		(*ePWM[j]).CMPA.bit.CMPAHR = (1 << 8);                 // initialize HRPWM extension
    		(*ePWM[j]).TBPHS.all = 0;
    
    		//Configure modes, clock dividers and action qualifier
    		(*ePWM[j]).TBCTR = 0;
    		(*ePWM[j]).TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;     // Select up-down count mode
    		(*ePWM[j]).TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
    
    		(*ePWM[j]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
    		(*ePWM[j]).TBCTL.bit.CLKDIV = TB_DIV1;                             // TBCLK = SYSCLKOUT
    		(*ePWM[j]).TBCTL.bit.FREE_SOFT = 0x00;
    
    		(*ePWM[j]).CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;      // LOAD CMPA on CTR = 0
    		(*ePWM[j]).CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
    		(*ePWM[j]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
    		(*ePWM[j]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;
    
    		(*ePWM[j]).AQCTLA.bit.CAU = AQ_SET;
    		(*ePWM[j]).AQCTLA.bit.CAD = AQ_CLEAR;
    //		(*ePWM[j]).AQCTLB.bit.ZRO = AQ_SET;
    //		(*ePWM[j]).AQCTLB.bit.PRD = AQ_CLEAR;
    
    		//added
    		(*ePWM[j]).DBCTL.bit.OUT_MODE = 0x2;//S1=1,S0=1
    		(*ePWM[j]).DBCTL.bit.POLSEL = 0x0;//S3=1,S2=0
    		(*ePWM[j]).DBCTL.bit.IN_MODE = 0x2;//S5=1,S4=0
    		(*ePWM[j]).DBRED.bit.DBRED = 20;//DC_DB_TIME_200NS;
    
    		//Configure HRPWM registers
    		EALLOW;
    		(*ePWM[j]).HRCNFG.all = 0x0;////
    		(*ePWM[j]).HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
    		(*ePWM[j]).HRCNFG.bit.CTLMODE = HR_CMP;
    		(*ePWM[j]).HRCNFG.bit.EDGMODE = 0x2;//control of both edges (TBPHSHR or TBPRDHR)
    		(*ePWM[j]).HRCNFG.bit.AUTOCONV = 1;  // Enable autoconversion
    		(*ePWM[j]).HRPCTL.bit.TBPHSHRLOADE = 1;
    		(*ePWM[j]).HRPCTL.bit.HRPE=1; // Turn on high-resolution period control.
    		EDIS;
        }
    		//Enable TBCLKSYNC
    	EALLOW;
    	CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    	//Perform a software sync
    	EPwm1Regs.TBCTL.bit.SWFSYNC = 1;
    }

    Thanks.

    Young

  • And code example "hrpwm_prdupdown_sfo_cpu01" was used to verify.

    Thanks.
  • Hi Nima,
    Any updates?
    Thanks.
    Regards,
    Young
  • Hello guys, I am experiencing the same issue with a TMS320F280049M. I am following the sample code from post 

    e2e.ti.com/.../189224

      In any case, doing UP_DOWN or UP only count, I get jitters with a size of 1 count (10nsec in my case per coarse step)... Any solution so far?

    Best regards,

    Alberto 

  • Yes the problem in the code is:


         (*ePWM[j]).HRCNFG.bit.HRLOAD  = HR_CTR_ZERO_PRD;    // load on CTR = 0 and CTR = TBPRD

    They MUST load on both ZERO and PERIOD.

    If they dont they will face that issue.

    TMS320F280049: PWM pin output signal is not stable when period and CMPA are fixed - C2000 microcontrollers...

    e2e.ti.com
    Part Number: TMS320F280049 Other Parts Discussed in Thread: C2000WARE Hi, Customer is using F28004x for their digital power application. Now we have a issue

    The link above is the same issue.

  • Hi Nima,

    Would you kindly help to check customer's HRPWM config code? Now the project is pending because of this issue.
    Thanks.

    Regards,
    Young
  • No problem. I'm going to try this in the lab.

    Nima

  • Is the customer hitting the range limitations?
    Please view the TRM and search for "Up-Down Count Duty Cycle Range Limitation Example". I suspect they may be violating the limitations of the PWM module.
  • Nima,
    I have checked "Up-Down Count Duty Cycle Range Limitation Example", 50% duty cycle was set, which cannot hit the limitation.
    Would you kindly help to test the code?
    My customer is waiting for our solution.
    Many thanks.
    Regards,
    Young
  • Yes, Absolutely. Could you send their CCS project so I have the exact same settings as them?

  • Hi Nima,

    You can refer the project from the following link, and unzip this file to C:\TI\controlSUITE\device_support\F2837xD\v210\F2837xD_examples_Cpu1.

    hrpwm_prdupdown_sfo_v8.zip

    Many thanks,

    Young

  • Found the issue. In  the HRPWM config function the code was not setting EDGEMODE to both edges. In the comment, it said "both edges" however in the customer code you sent me, the value used was "2". If you change that to "3" which is both edges as mentioned in the TRM, you see that the jitter will disappear. 

    So here is what I changed in the code: