Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed the week of November 23.

TMS320F28379D: Issue with HRPWM

Part Number: TMS320F28379D

Hello TI Team,

I am observing unexpected output glitches while testing HRPWM functionality on F28379D Launchpad.

I have kept TBPRD=100 and CMPA=64 fixed & varied CMPAHR from 0 to 255. I consistently observed glitches, as shown in below.

CMPAHR = 28 (CMPAHR < 128 & even)

image.png

CMPAHR = 251 (CMPAHR >128 & odd)

image.png

CMPAHR = 87

image.png

Could you help identify the root cause and suggest a solution?

 

  • Hi Hitesh,
    Two of your waveforms show the signal resting at ~1.2–1.5 V mid-pulse rather than a clean full-rail transition. A GPIO cannot drive an intermediate DC level, so this is more consistent with a probe/ground or scope-averaging artifact than an HRPWM logic glitch. Please confirm the probe setup and whether the capture is single-shot or averaged/persistence.
    Can you also provide more details on your configuration? 
    Are you implementing up count/ up down count mode?

  • --Orange Colored waveform - ePWM1A (HRPWM is not active)
    --Blue Colored waveform - ePWM2A (HRPWM is active)

    I have not connected any load to the GPIO; only the probe is connected, and I am monitoring it continuously. (No Probe related issues..)

    This issue does not appear when HRPWM is disabled.

    The problem appears under the following scenarios:

    1. When CMPAHR is loaded with a value less than 128 and the value is even, the glitch appears. The glitch does not occur when the value is odd.
    2. When CMPAHR is loaded with a value greater than 128 and the value is odd, the glitch appears. The glitch does not occur when the value is even.

    * I'm using up-dowm counter

    EPwm Configuration:

    ///////////////////////////////////////////////////////// EPWM 1A & 1B for PWM (MASTER)
    EPwm1Regs.TBCTL.bit.CLKDIV = 0;
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0;
    EPwm1Regs.TBCTL.bit.CTRMODE = 2;
    EPwm1Regs.TBCTL.bit.FREE_SOFT = 3;
    EPwm1Regs.TBCTL.bit.SYNCOSEL = 1; 
    EPwm1Regs.TBPRD = 100;
    EPwm1Regs.CMPCTL.bit.LOADAMODE = 2;
    EPwm1Regs.CMPA.bit.CMPA = 0;
    EPwm1Regs.AQCTLA.bit.CAD = 2;
    EPwm1Regs.AQCTLA.bit.CAU = 1;
    EPwm1Regs.DBCTL.bit.OUT_MODE = 3;
    EPwm1Regs.DBCTL.bit.POLSEL = 2;
    EPwm1Regs.DBCTL.bit.SHDWDBREDMODE = 1;
    EPwm1Regs.DBCTL.bit.LOADREDMODE = 1;
    EPwm1Regs.DBCTL.bit.SHDWDBFEDMODE = 1;
    EPwm1Regs.DBCTL.bit.LOADFEDMODE = 0;
    EPwm1Regs.DBRED.bit.DBRED = 5; 
    EPwm1Regs.DBFED.bit.DBFED = 5; 
    EPwm1Regs.ETSEL.bit.INTSEL = 3;
    EPwm1Regs.ETSEL.bit.INTEN = 1; 
    EPwm1Regs.ETPS.bit.INTPRD = 1;

    /////////////////////////////////////////////////////// EPWM 2A & 2B for HRPWM (SLAVE)
    EPwm2Regs.TBCTL.bit.CLKDIV = 0;
    EPwm2Regs.TBCTL.bit.HSPCLKDIV = 0;
    EPwm2Regs.TBCTL.bit.CTRMODE = 2;
    EPwm2Regs.TBCTL.bit.FREE_SOFT = 3;
    EPwm2Regs.TBCTL.bit.PHSDIR = 1;
    EPwm2Regs.TBCTL.bit.PHSEN = 1;
    EPwm2Regs.TBPHS.bit.TBPHS = 4; 

    EPwm2Regs.TBCTL.bit.SYNCOSEL = 0; 
    EPwm2Regs.TBPRD = 100;
    EPwm2Regs.CMPCTL.bit.LOADAMODE = 2;
    EPwm2Regs.CMPA.bit.CMPA = 0;
    EPwm2Regs.AQCTLA.bit.CAD = 2;
    EPwm2Regs.AQCTLA.bit.CAU = 1;
    EPwm2Regs.DBCTL.bit.OUT_MODE = 3;
    EPwm2Regs.DBCTL.bit.POLSEL = 2;
    EPwm2Regs.DBCTL.bit.SHDWDBREDMODE = 1;
    EPwm2Regs.DBCTL.bit.LOADREDMODE = 1;
    EPwm2Regs.DBCTL.bit.SHDWDBFEDMODE = 1;
    EPwm2Regs.DBCTL.bit.LOADFEDMODE = 0;
    EPwm2Regs.DBRED.bit.DBRED = 5; 
    EPwm2Regs.DBFED.bit.DBFED = 5; 
    EPwm2Regs.ETSEL.bit.INTSEL = 3;
    EPwm2Regs.ETPS.bit.INTPRD = 1;
    EPwm2Regs.ETSEL.bit.INTEN = 0; 

    ///////////////////////////////////////////////////////////////////////// HRPWM Configuration:
    EPwm2Regs.HRCNFG.bit.EDGMODE = 3;
    EPwm2Regs.HRCNFG.bit.CTLMODE = 0;
    EPwm2Regs.HRCNFG.bit.HRLOAD = 2;
    EPwm2Regs.HRPCTL.bit.HRPE = 1;


    ///////////////////////////////////////////////////////////////////////// CMPA Update:
    EPwm1Regs.CMPA.bit.CMPA = 64;
    EPwm2Regs.CMPA.all = (64UL << 16) | ((28U) << 8); 

  • Hi Hitesh,

    Root cause: most likely MEP calibration / CMPAHR write format, not the compare value itself

    First, your boundary conditions are clean: with TBPRD=100 and CMPA=64 you are well inside the required 3 ≤ CMPA ≤ TBPRD−3 window, so the documented "unexpected PWM transition" constraint is not being violated here 1. The glitches therefore point to configuration/calibration rather than edge placement.

    Check these in order:

    1. SFO / MEP scale factor is running. MEP step size varies with temperature and supply voltage, so the application must dynamically update the scale factor using the SFO library 3. If SFO is not called in a loop (or MEP_ScaleFactor is stale), CMPAHR values map to incorrect sub-cycle delays and edges move erratically as you sweep 0→255.

    2. CMPAHR bit alignment. CMPAHR is the 8-bit high-resolution extension of the compare value 1. Confirm you are writing the fraction into the upper byte of the CMPAHR field (i.e. value << 8) and not the lower byte. An unshifted write is a common source of the pattern you describe (behavior differing between even/odd and 128 values). Note: this is a configuration check flagged from your waveform captures, not a behavior documented in the retrieved TI literature.

    3. CMPAHR = 0 handling. A zero HR field can produce a one-TBCLK output jump; initializing the HR field to a nonzero value resolved this startup behavior in a reported case 5. If HR period control is disabled and CMPA is below three EPWMCLK cycles, CMPAHR must be cleared — the HRPWM logic is inactive during the first three EPWMCLK cycles of the period 1.

    4. Clocking. For SYSCLK above 100 MHz (the LaunchPad default is 200 MHz), EPWMCLK must be configured as SYSCLK/2 3.

    5. If you are using HR dead-band: enable DBCTL[HALFCYCLE], keep DBRED/DBFED ≥ 4, and update CMPAHR and CMPBHR together 6. Unsynchronized HR writes produce per-edge shifts that look like glitching at the pin.

    Two of your waveforms show the signal resting at ~1.2–1.5 V mid-pulse rather than a clean full-rail transition. A GPIO cannot drive an intermediate DC level, so this is more consistent with a probe/ground or scope-averaging artifact than an HRPWM logic glitch. Please confirm the probe setup and whether the capture is single-shot or averaged/persistence — this changes the diagnosis significantly.

    Information needed 

    The findings do not establish a specific CMPAHR update race or firmware root cause for your case. To confirm, please share:
    - Your HRCNFG setting (edge mode, control mode — duty vs. duty+period) 7
    - Whether SFO is being called and the returned status/MEP_ScaleFactor
    - The exact code line writing CMPAHR
    - Whether your action-qualifier events are on CMPA/CMPB or on ZRO/PRD — HRPWM precision edge control is unavailable near TBCTR=ZERO and TBCTR=TBPRD (approximately a three-TBCLK restriction), so edges should be placed via CMPA/CMPB 4


    1. TMS320F2837xD Technical Reference Manual (SPRUHM8K)
    2. TMS320F2837xD Dual-Core MCU Data Sheet (SPRS880P)
    3. E2E: High resolution period not stable with action qualifier ZRO and PRD
    4. E2E: Duty cycle of first period off by 1 TBCLK on HRPWM signal
    5. E2E: CMPAHR setting alters rising and falling edge delay at the physical output
    6. E2E: Is it possible to enable both TBPRDHR and CMPAHR at the same time