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.

simple epwm application, fixed frequency with variable duty cycle

Hello,

 

I have a very simple application where I want to use the F28335's epwm module to generate a tone for a piezo buzzer.

Here's how I'm setting up the PWM:

void InitEPwm1(void)

void InitEPwm1(void)

{

   //EPwm1Regs.

   EPwm1Regs.TBPRD = 6000;                       // Set timer period

   EPwm1Regs.TBCTR = 0x0000;                    // Clear counter

 

   // Setup TBCLK

   EPwm1Regs.TBCTL.bit.CTRMODE = 0;   // Count up

   EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0;       // Clock ratio to SYSCLKOUT

   EPwm1Regs.TBCTL.bit.CLKDIV = 0; //TBCLK = SYSCLKOUT / (HSPCLKDIV × CLKDIV

   EPwm1Regs.TBCTL.bit.PRDLD = 0;

   EPwm1Regs.TBCTL.bit.PHSEN = 0;

   // Setup compare    

   EPwm1Regs.CMPA.all = 3000;

 

   EPwm1Regs.CMPCTL.bit.SHDWAMODE = 1;     // immediate mode

   // Set actions

   EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR;           // low on CMPA 

   EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET; //high on zero

 

}

 

I'm getting a pulse train but it's not working the way I want and I can't figure out why.  I can't seem to influence either the frequency by changing EPwm1Regs.TBPRD nor can I influence the duty cycle by changing EPwm1Regs.CMPA.

 

All of the examples I've found are far more advanced then what I'm trying to do and in that sense, they aren't very helpful.  There's just too much information in the peripheral guide and it's making my head spin.  Any help would be greatly appreciated.  Thanks.

  • I think you need to show us the function where you change the period or the compare value.

    You may even want to show the memory view from location &EPwm1Regs (but this may not really be neccessary).

    I am assuming that your GPIO mux was configured correctly.