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.

trouble writing pwm register in f2808

I'm trying to use a F2808 for generating a PWM signal.

During the set up in the watch window i see all the register (gpio, adc, etc) updated with the correct values... but not the register for the ePWM

this is my inizialization code:

EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; //Fermo il clock di sistema verso le periferiche per sincronizzarle
EDIS;

EPwm1Regs.TBPRD = 600; // Period = 601 TBCLK counts
EPwm1Regs.CMPA.half.CMPA = 350; // Compare A = 350 TBCLK counts
EPwm1Regs.CMPB = 200; // Compare B = 200 TBCLK counts
EPwm1Regs.TBPHS.half.TBPHS = 0; // Set Phase register to zero
EPwm1Regs.TBCTR = 0; // clear TB counter
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Phase loading disabled
EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // TBCLK = SYSCLK
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR = Zero
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR = Zero
EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET;
EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR;
EPwm1Regs.AQCTLB.bit.ZRO = AQ_SET;
EPwm1Regs.AQCTLB.bit.CBU = AQ_CLEAR;

EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // riattivo il clock di sistema 
EDIS;

but after this EPwm1Regs contains only 0

and of course pwm signal is not working....

what can i do?

  • Gabriele,

    Is "EPwm1Regs.TBCTR" changing with time?

    If not, I would recommend checking on the EPwm1 clock signal to make sure that it is enabled:

    EALLOW;
    SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1;  // ePWM1
    EDIS;

    Several PWM projects within the "C280x/F280x Header Files and Example Projects" download can serve as a good place to start as well:
    http://www.ti.com/tool/sprc191


    Thank you,
    Brett

  • Thanks, Brett!

    I had the same problem with my 28377d.  All my registers were updating (GPIO, adc, etc) just fine with the exception of the ePWM.  I also had my ePWM setup nearly the same as Gabriel.  Unfortunately, I had forgotten to enable the ePWM clock signal that I have setup in a different function.  Once I enabled the clock (see code below), the registers were configurable.

    EALLOW
    CpuSysRegs.PCLKCR2.all = 1;
    EDIS;

    Thanks,

    Ryan