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/LAUNCHXL-F28069M: LAUNCHXL-F28069M Digitil Compare Submodule and DCAEVT1.sync

Part Number: LAUNCHXL-F28069M

Tool/software: Code Composer Studio

There is a ZCD signal input DSP, and then DSP output EPWM2A and EPWM2B, and their relationship is shown in Fig.1.

                                                                                             Fig.1

The ZCD connects to the TZ2(GPIO13) pin of DSP,when the rise edge of ZCD is coming,the Digital Compare (DC) Submodule of EPWM2 output the DCAEVT1.sync,as the Figure 3-47 shows. If the time between two rise edge is too small, it can use the Blanking Window to filter the second rise edge of ZCD.

As the Figure 3-5 shows, DCAEVT1.sync can load the TBPHS to TBCTR, then the TBCTR increase from zero. When the TBCTR is cleared, the EPWM2B is set. When the TBCTR equal to CMPB, the EPWM2B is cleared and the EPWM2A is set. When the TBCTR equal to CMPA, the EPWM2A is clear.

The experiment result:

CH4(green) is ZCD, CH2(light blue) is EPWM2A, CH1(dark blue) is EPWM2B

There are two questions:

  1. Why the EPWM2A is not 0V in red dashed box and the time is the same as the high level time of ZCD?
  2. The second rise edge of ZCD is 10us after the first rise edge. In code, the Blanking Window can filter the second rise edge of ZCD, but in experiment it failed, why?

There is the code and the hardware is LAUNCHXL-F28069M:

 

#include "math.h"

#include "DSP28x_Project.h"

 

void InitEPwm2Example(void);

 

int main(void) {

 

    InitSysCtrl();                                 // Initialize System Control

 

    InitGpio();                                     //Initialize GPIO

 

    InitEPwm2Gpio();

 

    InitTzGpio();

 

    //Configure ePWM module

    EALLOW;

    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;

 

    InitEPwm2Example();

 

    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;

    EDIS;

 

    //wait for timer0 interrupt

    for(;;);

}

 

void InitEPwm2Example(){

    // Setup TBCLK

    EPwm2Regs.TBCTL.bit.CTRMODE = 0x0;                  // Count up mode

    EPwm2Regs.TBPRD =4500;                               // Set timer period, for this example set at max value

    EPwm2Regs.TBCTL.bit.PHSEN = 0x1;                    // Enable phase loading

    EPwm2Regs.TBPHS.half.TBPHS = 0;                    // Phase is 0

    EPwm2Regs.TBCTR = 0x0000;                            // Clear counter

    EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;           // Clock ratio to SYSCLKOUT

    EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;

 

    // Setup shadow register load on ZERO

    EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;        // Load registers every ZERO

    EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;

    EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;

    EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;

 

    // Set Compare values

    EPwm2Regs.CMPA.half.CMPA = 720;                    // Set compare A value 8us

    EPwm2Regs.CMPB = 450;                              // Set compare B value 5us

 

    // Set actions

    EPwm2Regs.AQCTLA.bit.CBU = AQ_SET;                  // force EPWM1A output high; the high switch turn on

    EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR;               // force EPWM1A output low; the high switch turn off

    EPwm2Regs.AQCTLB.bit.ZRO = AQ_SET;                  // force EPWM1B output high; the low switch turn on

    EPwm2Regs.AQCTLB.bit.CBU = AQ_CLEAR;               // force EPWM1B output low; the low switch turn off

 

    //dead time

    EPwm2Regs.DBCTL.bit.IN_MODE = 0;                    // Clear PWM1B on event B, up count

    EPwm2Regs.DBCTL.bit.HALFCYCLE = 0;                  // Clear PWM1B on event B, up count

    EPwm2Regs.DBCTL.bit.POLSEL = 0;                     // Clear PWM1B on event B, up count

    EPwm2Regs.DBCTL.bit.OUT_MODE = 2;                   // Clear PWM1B on event B, up count

    EPwm2Regs.DBRED = 9;                                // Clear PWM1B on event B, up count 0.1us

 

    //DC

    EPwm2Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 1;           //TZ2 input

    EPwm2Regs.TZDCSEL.bit.DCAEVT1 = 2;                 //DCAH = high, DCAL = don't care

    EPwm2Regs.DCACTL.bit.EVT1SYNCE = 1;                //SYNC Generation Enabled

    EPwm2Regs.DCACTL.bit.EVT1SRCSEL = 0;               //0:Source Is DCAEVT1 Signal; 1:Source is DCEVTFILT Signal

 

    //Filter

    EPwm2Regs.DCFCTL.bit.PULSESEL = 1;                 //Time-base counter equal to zero

    EPwm2Regs.DCFCTL.bit.BLANKINV = 1;                 //Blanking window inverted

    EPwm2Regs.DCFCTL.bit.BLANKE = 1;                   //Blanking window is enabled

    EPwm2Regs.DCFCTL.bit.SRCSEL = 0;                   //Source is DCAEVT1 Signal

    EPwm2Regs.DCFOFFSET = 810;                         //Blanking Window Offset 9us

    EPwm2Regs.DCFWINDOW = 180;                         //Blanking Window Width 2us

}

 

  • Hello,

    The DC sub-module has the ability to force the PWM into a "High-Z" state through the Trip Zone sub-module. If this happens the device will no longer be driving the pin low. By default "High-Z" is selected, try switching this to a "Do Nothing" in TZCTL. 

    Regards,
    Cody 

  • Hello Cody Watkins,

    Thanks for your help.

    According to your advice, I modified the code and solved the first question.

     

    There are the original code and experimental results.

    //DC

    EPwm2Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 1; //TZ2 input

    EPwm2Regs.TZDCSEL.bit.DCAEVT1 = 2; //DCAH = high, DCAL = don't care

    EPwm2Regs.DCACTL.bit.EVT1SYNCE = 1;   //SYNC Generation Enabled

    EPwm2Regs.DCACTL.bit.EVT1SRCSEL = 0; //0:Source Is DCAEVT1 Signal; 1:Source is DCEVTFILT Signal

    And there are the modified code and experimental results.

    //DC
    EPwm2Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 1; //TZ2 input
    EPwm2Regs.TZDCSEL.bit.DCAEVT1 = 2; //DCAH = high, DCAL = don't care
    EPwm2Regs.DCACTL.bit.EVT1SYNCE = 1; //SYNC Generation Enabled
    EPwm2Regs.DCACTL.bit.EVT1SRCSEL = 0; //0:Source Is DCAEVT1 Signal; 1:Source is DCEVTFILT Signal
    EPwm2Regs.TZCTL.bit.DCAEVT1 = 3;

     Thank you again for your generous help!

  • Chenkai,

    It looks like to me you are blanking DCAEVT1. Is this the event you wanted to blank?

    It looks like you are using an 'inverted' blanking window, this means everything inside the window will NOT be blanked. Try using " EPwm2Regs.DCFCTL.bit.BLANKINV = 0".

    Your Offset(9uS) + Blanking window(2uS) are longer than your PWM period(10uS), this will cause a miss alignment between the blanking and the PWM period(this is not wrong, but I want to make sure you understand this is how you have it configured).

      • Would a shorter offset(~2uS) + blanking window(~6uS) work for your application?(see diagram below)
        • Be sure to use BLANKINV = 0 with this solution

    Regards,
    Cody

  • Cody,

     

    I want to blanking DCAEVT1. And the modified code is below:

       //DC

       EPwm2Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 1;           //TZ2 input

       EPwm2Regs.TZDCSEL.bit.DCAEVT1 = 2;                 //DCAH = high, DCAL = don't care

       EPwm2Regs.DCACTL.bit.EVT1SYNCE = 1;                //SYNC Generation Enabled

       EPwm2Regs.DCACTL.bit.EVT1SRCSEL = 0;               //0:Source Is DCAEVT1 Signal; 1:Source is DCEVTFILT Signal

       EPwm2Regs.TZCTL.bit.DCAEVT1 = 3;

       //Filter

       EPwm2Regs.DCFCTL.bit.PULSESEL = 1;                 //Time-base counter equal to zero

       EPwm2Regs.DCFCTL.bit.BLANKINV = 0;                 //Blanking window not inverted

       EPwm2Regs.DCFCTL.bit.BLANKE = 1;                   //Blanking window is enabled

       EPwm2Regs.DCFCTL.bit.SRCSEL = 0;                   //Source is DCAEVT1 Signal

       EPwm2Regs.DCFOFFSET = 810;                         //Blanking Window Offset 2us

       EPwm2Regs.DCFWINDOW = 180;                         //Blanking Window Width 6us

    But the experimental result is still wrong. My Offset(9uS) + Blanking window(2uS) are  not longer than my PWM period(20uS). Because of  the wrong singal at 10us, I want to use Blanking windows to ignore the wrong singal. 

    Thanks,

    Chenkai

  • Chenkai,

    I am very confused when you say your PWM period is 20uS. I think all of your signals have a period of 10uS am I reading the oscilloscope picture wrong?

    It looks to me like you want to use a blanking window every other PWM period, this is supported as long as your OFFSET< TBPRD. In other words you need to start your blanking window before the next period.

    It may help if you describe what you wanted to do again in a different way.

    Thanks,
    Cody 

  • Cody,

    In fact, I want to control a CrM (Critical Mode) Boost Circuit. When the inductor current reaches its valley, the ZCD signal gets a rise edge. When the inductor current reaches its peak, the ZCD signal gets a fall edge. The ZCD signal is sent to DSP.

    The reason why I want to use blanking window is that there is interference signal when the inductor current reaches its peak sometimes, as the Fig. 1 shows. The green waveform is my ZCD signal. It seems to be ok. But when you see the light blue waveform, it is the EPWMSYNCO signal, sometimes the light blue waveform get a pluse when the ZCD signal is fall edge. Therefore, I want to use the blanking window to filter the wrong pluse.

    Channel 1: EPWM1B; Channel 2: EPWM1SYNCO; Channel 3: Inductor Current; Channel 4: ZCD signal

    Fig. 1

    Before I use the code to my Boost circuit. I use the wave generator to generat the ZCD signal and interference signal to verify my code.

    As Fig.2 shows, the green waveform is generated by the waveform generator. Its period is 10us. It includes the ZCD signal and the interference signal. The first one rise edge is ZCD signal and the next is interference signal. So the ZCD signal's period is 20us and the interference signal is also 20us. I want the ZCD signal to control the PWM, and the interference signal is ignored by the blanking window. Therefore, I said my PWM period is 20us. And my OFFSET(9-11us)  is smaller than TBPRD(20us).

    In my opinion, if the coed is right, the first signal is ZCD signal, then the EPWM1B set high. After 6us, the EPWM1B clear. Then the second signal is interference signal come, it will be filter by blanking window, so the EPWM1B keep zero. But the experimental result do not match.

    Channel 1: EPWM1B; Channel 2:EPWM1A; Channel 4: ZCD signal

    Fig.2

    Thanks,

    Chenkai