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.

TMS320F28069M: C2000 ePWM without CMP Registers

Part Number: TMS320F28069M
Other Parts Discussed in Thread: C2000WARE

I am trying to generate a PWM signal with F28069M Launchpad using the code below. I wanted to generate a 50% duty cycle without using the Compare registers. However, the code below is not working as expected. What am I missing?

 

void InitEPwmTimer()

{

InitEPwm3Gpio();

EALLOW;

SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;

EDIS;

EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up

EPwm3Regs.TBPRD = 100; // Period of ePWM

EPwm3Regs.TBPHS.all = 0x00000000;

// EPwm3Regs.AQCTLA.bit.PRD = AQ_TOGGLE; // Toggle on PRD

// TBCLK = SYSCLKOUT

EPwm3Regs.TBCTL.bit.HSPCLKDIV = 1;

EPwm3Regs.TBCTL.bit.CLKDIV = 0;

EALLOW;

SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;

EDIS;

}

  • Andrew,

    I strongly recommend starting from one of the example in C2000Ware. Even though it will use the CMPx registers, it will also do all the small things for you like setup the GPIO configuration, PLL, and system clocks.

    Once you do that you should be able to use the AQ_TOGGLE setting as you have done above to reach a 50% duty cycle. please know that your period will be longer than expected because you are only toggling your PWM signal once per period.

    As for debugging the above, make sure the module clock is enabled, TBCTR is counting, ensure that the AQCTLA bits are correctly being written to(right now that code looks to be commented out)

    Please also make sure that you are observing the correct PWM, GPIO, and LaunchPad pins, these are very easy to get wrong and can cause a lot of confusion.

    Regards,
    Cody