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.

HRPWM outputs on 28035

Other Parts Discussed in Thread: CONTROLSUITE

I want to use outB of HRPWM independent from outA. But on HRPWM1 this does not work, for HRPWM2 und 3 it works. Had anyone this problem beofre?


Here is my initialisation:

void HRPWM1_Config(period)
{
// ePWM1 register configuration with HRPWM
// ePWM1A toggle low/high with MEP control on Rising edge
    EALLOW;
    EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;            // set Immediate load
       EPwm1Regs.TBCTL.bit.FREE_SOFT = 11;
    EPwm1Regs.TBPRD = period-1;                            // PWM frequency = 1 / period
    EPwm1Regs.CMPA.half.CMPA = period / 2;              // set duty 50% initially
    EPwm1Regs.CMPA.half.CMPAHR = (1 << 8);              // initialize HRPWM extension
//    EPwm1Regs.CMPB = period / 2;                        // set duty 50% initially
    EPwm1Regs.TBPHS.all = 0;
    EPwm1Regs.TBCTR = 0;

    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
    EPwm1Regs.TBCTL.bit.PHSEN = TB_ENABLE;               // EPwm1 is the Master
    EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
    EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;

    EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
    EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
    EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
    EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;

    EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR;               // PWM toggle low/high
    EPwm1Regs.AQCTLA.bit.CAD = AQ_SET;
    EPwm1Regs.AQCTLB.bit.CAU = AQ_CLEAR;
    EPwm1Regs.AQCTLB.bit.CAD = AQ_SET;

    EPwm1Regs.ETSEL.bit.SOCAEN    = 1;                       //enable SOCA pulse generation
    EPwm1Regs.ETSEL.bit.SOCASEL    = ET_CTR_PRD;        //pulse on counter equals period
    EPwm1Regs.ETPS.bit.SOCAPRD     = ET_1ST;                //pulse on every event

    EPwm1Regs.HRCNFG.all = 0x0;
    EPwm1Regs.HRCNFG.bit.EDGMODE = HR_BEP;                //MEP control both edges
    EPwm1Regs.HRCNFG.bit.SELOUTB = HR_NORM_B;            //Chan. B
    EPwm1Regs.HRCNFG.bit.CTLMODE = HR_CMP;
    EPwm1Regs.HRCNFG.bit.HRLOAD  = HR_CTR_ZERO_PRD;      //HR_CTR_ZERO;
    EPwm1Regs.HRCNFG.bit.AUTOCONV  = 1;                //Autoconversion ist an

    EPwm1Regs.HRPCTL.bit.TBPHSHRLOADE = 1;
    EPwm1Regs.HRPCTL.bit.HRPE = 1;
//    EPwm1Regs.HRPWR.bit.MEPOFF = 0xF;

    // Configure EPWM-1 pins using GPIO regs
    GpioCtrlRegs.GPAPUD.bit.GPIO0 = 1;    // Disable pull-up on GPIO0 (EPWM1A)
    GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1;    // Disable pull-up on GPIO1 (EPWM1B)

    GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1;   // Configure GPIO0 as EPWM1A
    GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1;   // Configure GPIO1 as EPWM1B

    EDIS;

}

Regards, Peter

  • Hi Peter,

    Did you try with the HRPWM example code present in controlSuite?

    Regards,

    Gautam

  • Hi Gautam,

    the code was initially using the controlSuite example. Now I want to use outB of the modlues as separate PWM outputs. In my first hardware version, the outputs was digital used, but now I want to dimm an LED on each outB.

    I have 3 PWM outputs. On HRPWM2 and 3, the separate outputs works, but not on HRPWM1. The difference is only in SYNC unit (PWM1 as master, other as slave)

    Regards

    Peter

  • Hi all,

    the problem is still not solved, is there any idea about this issue?

    Peter

  • Hi Peter,

    I have not seen an issue like this previously.

    If PWM2 is working and PWM1 is not, how is PWM1's configuration different from PWM2?

    One thing that I notice above is that PHSEN should be set to TB_DISABLE for the master.  This shouldn't cause an issue in your case, but it is a more correct implementation. 


    Thank you,
    Brett

  • Hi Brett,

    thank you for your hint. My initialisation for PWM2 is nearly the same see below. Any ideas?

    Regards, Peter

    void HRPWM2_Config(period)
    {
    // ePWM2 register configuration with HRPWM
    // ePWM2A toggle high/low with MEP control on falling edge
        EALLOW;
        EPwm2Regs.TBCTL.bit.PRDLD = TB_SHADOW;            // set Immediate load
        EPwm2Regs.TBCTL.bit.FREE_SOFT = 11;
        EPwm2Regs.TBPRD = period-1;                            // PWM frequency = 1 / period
        EPwm2Regs.CMPA.half.CMPA = period / 2;              // set duty 50% initially
        EPwm2Regs.CMPA.half.CMPAHR = (1 << 8);              // initialize HRPWM extension
        EPwm2Regs.TBPHS.all = 0;
        EPwm2Regs.TBCTR = 0;

        EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
        EPwm2Regs.TBCTL.bit.PHSEN = TB_ENABLE;                // EPwm3 is the Master
        EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
        EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
        EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;

        EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
        EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
        EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
        EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;

        EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR;                  // PWM toggle high/low
        EPwm2Regs.AQCTLA.bit.CAD = AQ_SET;
        EPwm2Regs.AQCTLB.bit.CBU = AQ_CLEAR;
        EPwm2Regs.AQCTLB.bit.CBD = AQ_SET;

        EPwm2Regs.ETSEL.bit.SOCAEN    = 1;                       //enable SOCA pulse generation
        EPwm2Regs.ETSEL.bit.SOCASEL    = ET_CTR_ZERO;        //pulse on counter equals zero
        EPwm2Regs.ETPS.bit.SOCAPRD     = ET_1ST;                //pulse on every event
        EPwm2Regs.ETSEL.bit.INTEN = 1;
        EPwm2Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO;
        EPwm2Regs.ETPS.bit.INTPRD     = ET_1ST;

        EPwm2Regs.HRCNFG.all = 0x0;
        EPwm2Regs.HRCNFG.bit.EDGMODE = HR_BEP;               //MEP control both edges
        EPwm2Regs.HRCNFG.bit.SELOUTB = HR_NORM_B;            //Chan. B
        EPwm2Regs.HRCNFG.bit.CTLMODE = HR_CMP;
        EPwm2Regs.HRCNFG.bit.HRLOAD  = HR_CTR_ZERO_PRD;
        EPwm2Regs.HRCNFG.bit.AUTOCONV  = 1;                //Autoconversion ist an

        EPwm2Regs.HRPCTL.bit.TBPHSHRLOADE = 1;
        EPwm2Regs.HRPCTL.bit.HRPE = 1;

        // Configure EPWM-2 pins using GPIO regs
        GpioCtrlRegs.GPAPUD.bit.GPIO2 = 1;    // Disable pull-up on GPIO2 (EPWM2A)
        GpioCtrlRegs.GPAPUD.bit.GPIO3 = 1;    // Disable pull-up on GPIO3 (EPWM2B)

        GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1;   // Configure GPIO2 as EPWM2A
        GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 1;   // Configure GPIO3 as EPWM2B

        EDIS;
    }

  • Hi Peter,

    Can you define what, "on HRPWM1 this does not work" means?  Does the B channel output of HRPWM1 stay high, low, or does it behave in an unexpected manner?

    I have one thought:
    In the HRPWM guide for the F28035, you will find a section on the proper configuration order for HRPWMs.  This includes disabling TBCLKSYNC prior to all PWM configuration and enabling TBCLKSYNC afterward.  I would recommend making sure that your configuration follows the order described in the documentation.

    Outside of this, as you mentioned, the two PWM configurations look similar.  If you have a second MCU/board, does the same thing happen on it?  Have you ruled out your board hardware, leaving us with only the F28035 to blame?


    Thank you,
    Brett