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.

ePWM start/stop problem

Other Parts Discussed in Thread: TMS320F28335

Hello!

I have a problem with ePWM on TMS320F28335 DSC.

In my application I have a two MOSFET and I need to operate this with ePWM. Somtimes I need to Enable/Disable of ePWM (set both PWM signal to HI level).

My code for Enable and Disable of PWM is:

void EPWM1_Disable(void)
{
	EPwm1Regs.AQSFRC.bit.RLDCSF = 3;
	EPwm1Regs.AQSFRC.bit.ACTSFA = 2;
	EPwm1Regs.AQSFRC.bit.ACTSFB = 2;
	EPwm1Regs.AQSFRC.bit.OTSFA = 1;
	EPwm1Regs.AQSFRC.bit.OTSFB = 1;
	EPwm1Regs.AQCSFRC.bit.CSFA = 2;
	EPwm1Regs.AQCSFRC.bit.CSFB = 2;
	EPwm1Regs.DBCTL.bit.OUT_MODE = 0;
}
void EPWM1_Enable(void)
{
	EPwm1Regs.AQSFRC.bit.RLDCSF = 0;
	EPwm1Regs.AQSFRC.bit.ACTSFA = 0;
	EPwm1Regs.AQSFRC.bit.ACTSFB = 0;
	EPwm1Regs.AQSFRC.bit.OTSFA = 0;
	EPwm1Regs.AQSFRC.bit.OTSFB = 0;
	EPwm1Regs.AQCSFRC.bit.CSFA = 3;
	EPwm1Regs.AQCSFRC.bit.CSFB = 3;
	EPwm1Regs.DBCTL.bit.OUT_MODE = 3;
}

My source code for configurate ePWM:

void EPWM1_Config(unsigned short int period, unsigned short int duty)
{
	EPwm1Regs.TBPRD = period;
	EPwm1Regs.TBPHS.half.TBPHS = 0;
	EPwm1Regs.TBCTL.bit.CLKDIV = 0;
	EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0;
	EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
	EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;
	EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;
	EPwm1Regs.AQSFRC.bit.RLDCSF = TB_SHADOW;
	EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
	EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
	EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
	EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
	EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
	EPwm1Regs.AQCTLA.bit.CAU = AQ_SET;
	EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;
	EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
	EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_LOC;
	EPwm1Regs.DBFED = MY_DEAD_TIME_DBFED;
	EPwm1Regs.DBRED = MY_DEAD_TIME_DBRED;
	EPwm1Regs.CMPA.half.CMPA = duty;
	EPwm1Regs.ETSEL.all = 0;
	EPwm1Regs.ETSEL.bit.INTEN = 1;
	EPwm1Regs.ETSEL.bit.INTSEL = 2;
	EPwm1Regs.ETPS.bit.INTPRD = 1;
}

This code is working but there there is a problem when I use EPWM1_Enable(void) function. Please see Image below:

Active level - LOW, green signal - EPWM1A, Yellow - EPWM1B

When I start ePWM signal EPWM1A go to ACTIVE level and the next go to NOT active level. The length of this process = one period of ePWM counter.

Here:

  1. The ePWM is Disable
  2. Start ePWM. This pulse - is my problem. This should not occur.
  3. Normal operate.
  4. Change level. No death band here (in my program I use death band about 400 ns)

How can I fix it? I have to get rid of this pulse during the enable ePWM.

Best regards,

Alex

  • Alex,

    When you run EPWM1_Enable(), the first line sets the reload condition from "immediate" to "counter=zero".  This means the two later writes to the ACQSFRC register will only happen at the end of the current PWM period, not immediately (as happens in the disable function).  

    However, in the last line of the function you are switching the dead-band module from "by-pass" to "active-low complementary" (defined by the POLSEL field in your configuration code).  This is immediate, so if you are calling EPWM1_Enable at the start of a PWM period, there will be 1 PWM period during which the outputs are active-low complementary before the software force takes effect.  I think that's what you're seeing.

    What happens if you keep RLDCSF at 3 - does that fix it?

    Regards,

    Richard

  • Hello Richard !

    Thank you for your answer.

    I have tried to set RLDCSF at 3 in EPWM1_Enable() function but it has not brought results. I see again this pulse:

    void EPWM1_Enable(void)
    {
    	EPwm1Regs.AQSFRC.bit.RLDCSF = 3;
    	EPwm1Regs.AQSFRC.bit.ACTSFA = 0;
    	EPwm1Regs.AQSFRC.bit.ACTSFB = 0;
    	EPwm1Regs.AQSFRC.bit.OTSFA = 0;
    	EPwm1Regs.AQSFRC.bit.OTSFB = 0;
    	EPwm1Regs.AQCSFRC.bit.CSFA = 3;
    	EPwm1Regs.AQCSFRC.bit.CSFB = 3;
    	EPwm1Regs.DBCTL.bit.OUT_MODE = 3;
    }

    It has something to do with the fact that some register shadowed, but some registers is NOT shadowed.

    In my program ePWM operate in Active LOW Complementary (ALC) mode. In this mode I'm operate of MOSFET transistors, but sometimes I need to stop ePWM for close all transistors (disable my device). My MOSFETs is close when ePWM output is HI.

    In this case I need normaly operate in ALC mode, but sometimes set all lines in HI. Mayby there is another solution for this?

    Best regards,

    Alexander Kuznetsov.

  • Alexander,

    Can you try using trip zone to enable and disable instead?
    You can force a trip condition suing TZFRC reg. Select the force action on PWM output A/B to be High in TZCTL.

    -Bharathi.
  • Dear Bharathi,

    Thank you very much for your answer. It's was be very helpful. Now I use a Trip-Zone feature for manualy start/stop ePWM. It's correctly work.

    But I need shadowed copy of registers EPwm1Regs.TZFRC.bit.OST and EPwm1Regs.TZCLR.bit.OST

    Are there these registers?

    Best regards, Alexander

  • Alexander,

    Good to know it worked for you. These are not shadowed registers.
    So the force would occur whenever the register is written to.
    You can try EPwm1Regs.TZFRC.bit.CBC, instead of OST, if it helps.
    If you use CBC - the trip will be cleared at CNT_Zero, force would still occur at time when s/w writes to this reg.

    -Bharathi.

  • Dear Bharathi,
    thank you very much!

    My problem is solved!

    Best regards, Alexander
  • IF i enabled the Trip zone (single shot) to disable my PWM using the TZFRC register. To re enable PWM, can i just set the TZFRC.OST bit to zero or i should set TZCLR.bit to 1 by which my PWM will resume immidiately ?
  • Hello!

    For example (for EPWM1) for disable it: EPwm1Regs.TZFRC.bit.OST = 1;

    and for eneble it: EPwm1Regs.TZCLR.bit.OST = 1;