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/TMS320F28379D: TMS320F28379D

Part Number: TMS320F28379D
Other Parts Discussed in Thread: TIDM-02002

Tool/software: Code Composer Studio

Hello everyone,

I am working with TMS320F28379D module. I was trying to understand HRPWM. I am currently stuck with Phase shifting. I am working with examples named, hrpwm_prdupdown and hrpwm_duty_up. I was trying to put some value into TBPHS.bit.TBPHS like 0xA000 to create phase shifting. But it's not working. 

I have set the

1. TBCTL.bit.PHSEN to TB_ENABLE

2. HRCNFG.bit.EDGMODE = HR_BEP;

3. HRCNFG.bit.CTLMODE = HR_PHS; 

4. HRCNFG.bit.HRLOAD = HR_CTR_ZERO_PRD; 

5. HRCNFG.bit.EDGMODEB = HR_BEP; 

6. HRCNFG.bit.CTLMODEB = HR_PHS;  

7. HRCNFG.bit.HRLOADB = HR_CTR_ZERO_PRD; 

8. HRCNFG.bit.AUTOCONV = 1;  

9. HRPCTL.bit.TBPHSHRLOADE = 1; 

After doing these, it's still not working.

My questions:

1. Can anyone help me to understand how can I create phase shifting between the HRPWM 1, HRPWM 2 etc. ?  Can anyone provide me a sample code for phase HRPWM shifting?

2. My primary goal is to create a Full bridge using controlled phase shifting and duty. Is there any sample code for this purpose? 

I will be pretty glad if anyone can help me out.

Thank you

Shamsul Arefeen

  • What you say it isn't working, I assume you mean the phase shifting specifically and that the waveforms are otherwise okay, correct? What kind of sync event (SYNCIN, TBCTL[SWFSYNC], etc...) are you using?

    Whitney
  • Yes, waveforms are ok and I can control the period and duty cycle properly. I am having a problem with phase shifting. I am using TB_SYNC_DISABLE and TBCTL.bit.SWFSYNC = 1. 

    I am providing the code for the registers,

    (*ePWM[j]).TBCTL.bit.PRDLD = TB_SHADOW;  // set Shadow load

            (*ePWM[j]).TBPRD = period;               // 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]).CMPB.bit.CMPB = period / 2;   // set duty 50% initially

            (*ePWM[j]).CMPB.all |= 1;

            (*ePWM[j]).TBPHS.bit.TBPHS = 1000;

            (*ePWM[j]).TBCTR = period;

            (*ePWM[j]).TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Select up-down

            (*ePWM[j]).TBCTL.bit.PHSEN = 1; //TB_ENABLE;                                                // 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 = 11;

            //(*ePWM[j]).HRPCTL.bit.TBPHSHRLOADE = 1;

            (*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;             // PWM toggle high/low

            (*ePWM[j]).AQCTLA.bit.CAD = AQ_CLEAR;

            (*ePWM[j]).AQCTLB.bit.CBU = AQ_SET;             // PWM toggle high/low

            (*ePWM[j]).AQCTLB.bit.CBD = AQ_CLEAR;

            EALLOW;

            (*ePWM[j]).HRCNFG.all = 0x0;

            (*ePWM[j]).HRCNFG.bit.EDGMODE = HR_BEP;       

            (*ePWM[j]).HRCNFG.bit.CTLMODE = HR_PHS;   

            (*ePWM[j]).HRCNFG.bit.HRLOAD = HR_CTR_ZERO_PRD;  

            (*ePWM[j]).HRCNFG.bit.EDGMODEB = HR_BEP;        

            (*ePWM[j]).HRCNFG.bit.CTLMODEB = HR_PHS;      

            (*ePWM[j]).HRCNFG.bit.HRLOADB = HR_CTR_ZERO_PRD; 

            (*ePWM[j]).HRCNFG.bit.AUTOCONV = 1;      

            (*ePWM[j]).HRPCTL.bit.TBPHSHRLOADE = 1;   

            (*ePWM[j]).HRPCTL.bit.HRPE = 1;    

            CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;   

           (*ePWM[j]).TBCTL.bit.SWFSYNC = 1;       

  • Hello, Can you suggest me how can I do the phase shifting for HRPWM? I have shared all the register value in my previous comment. If you have any sample code can you share that with me?
  • Thanks for your patience. Have you been able to get it working? What period value are you using? Are you keeping in mind that TBPHS values need to be left-shifted? Are you able to get a non-high res phase shift working?

    The only example I can think of at the moment that contains HRPWM and appears to have phase shifting enabled is the TIDM-02002 project in the DigitalPower SDK. Do you have that package installed?

    Whitney

  • Hello,

    Thanks for your reply. I couldn't solve it yet. 

    The period value is 24 (decimal). I was not sure about TBPHS values. I tried to do phase shifting using EPWM, it seemed working. I need to recheck that again. For high resolution phase shifting is not working at all. 

    I haven't installed the Digital Power SDK package. I will install it now and try to see that example. I am attaching my whole code in this message.

    hrpwm_ex2_prdupdown_sfo_v8.ziphrpwm_ex2_prdupdown_sfo_v8.zip

  • The code you attached appears to just be an exact copy of the HRPWM up-down example for the F28004x. Did you mean to attach something else? I thought you were using the F2837xD and had made some edits to the code...?

    Whitney
  • Hello,

    Yes, this is the HRPWM_prdupdown code. I was trying to change TB_PHSEN and TBPHS register values. I have made some changes now by creating two HRPWM to control epwm1 and epwm2 individually. I am attaching the code here.8883.hrpwm_prdupdown_sfo_v8.zip

  • I ran your code and was able to try different TBPHS values and see the affect on the signals on my oscilloscope. Does that not work for you? Do you still not see the expected waveforms?

    Whitney