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.

TMS320F280049C: HRPWM mode not working with shadow mode set to load on CTR=PRD

Part Number: TMS320F280049C
Other Parts Discussed in Thread: C2000WARE, TMS320F28379D

I cannot get high-res output on ePWM1 when using shadow mode set to load on CTR=PRD. I’ve taken the hrpwm_ex1_duty_sfo C2000ware HRPWM example and modified to demonstrate this (code pasted below).

I can see that with the HRPWM shadow load event set to HRPWM_LOAD_ON_CNTR_ZERO there is a fine resolution on the PWM duty cycle output. However, with HRPWM_LOAD_ON_CNTR_PERIOD there is not. Is this a known restriction?

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//#############################################################################
//
// FILE: hrpwm_ex1_duty_sfo.c
//
// TITLE: HRPWM Duty Control with SFO.
//
//! \addtogroup driver_example_list
//! <h1>HRPWM Duty Control with SFO</h1>
//!
//! This example modifies the MEP control registers to show edge displacement
//! for high-resolution period with ePWM in Up count mode
//! due to the HRPWM control extension of the respective ePWM module.
//!
//! This example calls the following TI's MEP Scale Factor Optimizer (SFO)
//! software library V8 functions:
//!
//! \b int \b SFO(); \n
//! - updates MEP_ScaleFactor dynamically when HRPWM is in use
//! - updates HRMSTEP register (exists only in EPwm1Regs register space)
//! with MEP_ScaleFactor value
//! - returns 2 if error: MEP_ScaleFactor is greater than maximum value of 255
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hello Guz,

    I have not been able to observe such things on the TMS320F28379D. What values are set in the EPwm1Regs.CMPCTL.LOADAMODE and LOADBMODE. Maybe you try it with: EPwm1Regs.CMPCTL.LOADAMODE = 0x01; EPwm1Regs.CMPCTL.LOADBMODE = 0x01; In the Else part of your Init.

    Best regards

    Leon

  • Hi Leon, I did try that as well, but I had no effect. The only time I saw high-res PWM output was when HRCNFG.HRLOAD = 0x00.

  • Gus, let me try and find my code with HRPWM in UP-COUNT MODE.

    Did this original example use UP-COUNT mode?

  • I probably wrote this example myself, but I don't remember... I should still have all of old files.

  • The HRPWM example I have:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    //
    // Set up counter mode
    //
    EPWM_setTimeBaseCounterMode(ePWM[j], EPWM_COUNTER_MODE_UP);
    EPWM_disablePhaseShiftLoad(ePWM[j]);
    EPWM_setClockPrescaler(ePWM[j],
    EPWM_CLOCK_DIVIDER_1,
    EPWM_HSCLOCK_DIVIDER_1);
    EPWM_setSyncOutPulseMode(ePWM[j], EPWM_SYNC_OUT_PULSE_DISABLED);
    //
    // Set up shadowing
    //
    EPWM_setCounterCompareShadowLoadMode(ePWM[j],
    EPWM_COUNTER_COMPARE_A,
    EPWM_COMP_LOAD_ON_CNTR_PERIOD);
    EPWM_setCounterCompareShadowLoadMode(ePWM[j],
    EPWM_COUNTER_COMPARE_B,
    EPWM_COMP_LOAD_ON_CNTR_PERIOD);
    //
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    This REQUIRED the LOAD settings to be:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    HRPWM_setMEPEdgeSelect(ePWM[j], HRPWM_CHANNEL_A, HRPWM_MEP_CTRL_FALLING_EDGE);
    HRPWM_setMEPControlMode(ePWM[j], HRPWM_CHANNEL_A, HRPWM_MEP_DUTY_PERIOD_CTRL);
    HRPWM_setCounterCompareShadowLoadEvent(ePWM[j], HRPWM_CHANNEL_A, HRPWM_LOAD_ON_CNTR_ZERO_PERIOD);
    HRPWM_setMEPEdgeSelect(ePWM[j], HRPWM_CHANNEL_B, HRPWM_MEP_CTRL_FALLING_EDGE);
    HRPWM_setMEPControlMode(ePWM[j], HRPWM_CHANNEL_B, HRPWM_MEP_DUTY_PERIOD_CTRL);
    HRPWM_setCounterCompareShadowLoadEvent(ePWM[j], HRPWM_CHANNEL_B, HRPWM_LOAD_ON_CNTR_ZERO_PERIOD);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Nima,

    Thanks for looking into this. I do see that with the load setting changed to HRPWM_LOAD_ON_CNTR_ZERO_PERIOD the high-res output works as expected.