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 On duty cycle fall out / extra switching when unwanted. TMS32028035

Other Parts Discussed in Thread: TMS320F28035, CONTROLSUITE

I'm having an issue with the ePWM on a TMS320F28035.   I would like to generate a pure 100kHz square wave form duty cycle with no higher frequency switching.  Output High duty cycle looks like a comb... _____|`|_|`|_|`|_|`|____    I want it to look like _____|``````````````|______

 

I've been trying to get this working for a few weeks now and have NOT been able to get this working correctly.

 

heres my code...

void

InitEPwm1Example()

{

EALLOW;

EPwm1Regs.

TBCTR = 300;

EPwm1Regs.

TBPRD = 300; // Set timer period 150x2=300 TBCLKs

EPwm1Regs.

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

EPwm1Regs.

TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Set up down count mode

EPwm1Regs.

TBCTL.bit.PHSEN = TB_DISABLE; // disable phase off set

EPwm1Regs.

TBCTL.bit.PRDLD = TB_SHADOW;

EPwm1Regs.

TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; // sync on timer b = 0

EPwm1Regs.

TBCTL.bit.CLKDIV = TB_DIV1;

EPwm1Regs.

TBCTL.bit.HSPCLKDIV = TB_DIV1;

EPwm1Regs.

CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Setup shadowing

EPwm1Regs.

CMPCTL.bit.SHDWBMODE = CC_SHADOW;

EPwm1Regs.

CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // Load on Zero

EPwm1Regs.

CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;

EPwm1Regs.

AQCTLA.bit.CAU = AQ_SET; // was AQ_CLEAR; // when compare A count up = compare value... set high

EPwm1Regs.

AQCTLA.bit.CAD = AQ_CLEAR;// was AQ_SET; // when compare A count down = compare value... set low/clear

EPwm1Regs.

AQCSFRC.bit.CSFA = 0x10;  // Force Output High on PWMA.

EPwm1Regs.

AQCSFRC.bit.CSFB = 0x10;  // Force Output High on PWMB.

EPwm1Regs.

DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // enable dead band

EPwm1Regs.

DBCTL.bit.POLSEL = DB_ACTV_HIC; // dead band active on high compare

EPwm1Regs.

DBFED = 0; // falling edge delay

EPwm1Regs.

DBRED = 0; // rising edge delay

 

EPwm1Regs.

PCCTL.bit.CHPEN = CHP_DISABLE; // disable PWM chopping

 

EPwm1Regs.

CMPA.half.CMPA = 0;// was Duty1_scale; //was 300   // Set compare A value to EPWM1_MIN_CMPA // DUTY CYCLE PERCENT CONTROL... (100= 1/3 high; 200= 2/3 high)

// EPwm1Regs.CMPB = 150;     //was 150          // Set Compare B value

 

 

 

  

// Define an event (DCAEVT1) based on TZ1 and TZ2

   EPwm1Regs.

DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP1OUT;   // DCAH = Comparator 1 output

   EPwm1Regs.

DCTRIPSEL.bit.DCALCOMPSEL = DC_TZ2;        // DCAL = TZ2

   EPwm1Regs.

TZDCSEL.bit.DCAEVT1 = TZ_DCAH_LOW; // DCAEVT1 =  DCAH low, DCAL high;

   EPwm1Regs.

DCACTL.bit.EVT1SRCSEL = DC_EVT1;           // DCAEVT1 = DCAEVT1 (not filtered)

   EPwm1Regs.

DCACTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;  // Take async path

 

  

// Enable DCAEVT1 as a one-shot trip source

  

// Note: DCxEVT1 events can be defined as one-shot.

  

//       DCxEVT2 events can be defined as cycle-by-cycle.

   EPwm1Regs.

TZSEL.bit.DCAEVT1 = 0; // was 1

  

// What do we want the one-shot trip to do?

  

// Because DCAEVT1 is causes a trip event

  

// (in this case one-shot) we need to use the TZA

  

// the and TZB actions to force EPWM1A and EPWM1B

  

// Note: TZA and TZB have higher priority over the

  

//       DCAEVT2 action.

   EPwm1Regs.

TZCTL.bit.DCAEVT1 = TZ_FORCE_LO;           // EPWM1A will go high

//    EPwm1Regs.TZCTL.bit.DCAEVT1 = TZ_FORCE_LO;           // EPWM1B will go low

  

// Enable TZ interrupt

   EPwm1Regs.

TZEINT.bit.CBC = 1; // set to cycle by cycle comparator trip

   EDIS;

}

 

 

When I generate a 100 percent duty cycle On output at 100kHz... I get a 100kHz square wave form with the voltage dropping from 3.3v to 0 at a rate of 1MHz and then turning back on to 3.3v.

 

How do I get a steady 3.3v output high on time with ePWM generation?

  • Randy,

    I'm not sure if I'm understanding you correctly.  You're just saying you want to generate 100 kHz symmetric PWM with 50% duty cycle?

    If so, download the code for appnote SPRA958.

    http://www.ti.com/mcu/docs/litabsmultiplefilelist.tsp?sectionId=96&tabId=1502&literatureNumber=spra958l&docCategoryId=1&familyId=1414

    Look at the example F28035_nonBIOS_RAM.  This is a fully self-contained CCSv5.3.0 project.  As it is written, it generates 2 kHz, 25% duty symmetric PWM on PWM1A pin (GPIO0).  You can easily modify this by editing the file include\F28035_example.h.  Change the #defines for PWM_HALF_PERIOD and PWM_DUTY_CYCLE to do what you want:

    //#define PWM_HALF_PERIOD  15000   // period/2 for 2 kHz symmetric PWM w/ 60 MHz SYSCLKOUT
    //#define PWM_DUTY_CYCLE   11250   // 25% duty cycle
    #define PWM_HALF_PERIOD  300    // period/2 for 100 kHz symmetric PWM w/ 60 MHz SYSCLKOUT
    #define PWM_DUTY_CYCLE   150    // 50% duty cycle 

    Not sure what is going on in your code, but the code I cited works.  Note I am running F28035 at 60 MHz from the internal OSC1 clock source.  Be careful if you run this code on your own board.  As I said, it outputs on PWM1A pin (GPIO0) and also toggles GPIO34 which is an LED on the TI EVMs.  You don't want to blow anything up on your board.  Read Section 8 of the appnote for a description of what the code does.

    Regards,

    David 

     

  • problem is  _|````````````|______|```````````|____      looks like _|`|`|`|`|`|`|______|`|`|`|`|`|`|`|____  on my o-scope at 1ns Time/Div.   I want to know how to get a PWM signal out that doesn't have this drop from high to low and back to high durring the on time.

  • Very well.  I see you have it disabled, but the waveform you show looks like the chopper module is enabled.  I suspect your drawing is not to scale.

    OK, run the code I cited in appnote SPRA958 and see if it has the same problem.  It shouldn't.

    - David

  • Cant find that code example or app note SPRA958.   I loaded Example_2803xEPwmBlanking and TripPWM from ControlSuite to CCS 5.3.  When I look at the PWM On time at 1 ns/ Time division I still see the ___|`|`|`|`|`|_____|`|`|`|`|`|`|______   instead of ___|`````````|______|``````````|______ .

  • There is a link to the appnote in my earlier post.  Alternately, just go to www.ti.com and put 'SPRA958' in the search box.

    But if you've already tried an example from ControSuite and it has the same problem, I'd say you've got a hardware issue or a scope issue.

    - David