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: Jitter when using HRPWM Period Control

Part Number: TMS320F280049C
Other Parts Discussed in Thread: TMDSCNCD280049C, , C2000WARE, SYSCONFIG

Hello all,
I am trying to generate a PWM signal with my C2000 microcontroller. However, when I use the HRPWM, I see that the output jitters. For configuration I used .syscfg in CCS and I do not understand what I am doing wrong.

I am using the TMS320F280049C which is integrated into a control card (TMDSCNCD280049C). I am using Code Composer Studio version 12.1.0.00007 for programming.

I want to implement a PWM frequency up to 10 MHz with a constant duty cycle of 50% and a configurable dead time. The frequency needs to be set with high resolution. I get jitter when I enable HRPWM period control (in .syscfg or with the driverlib function HRPWM_enablePeriodControl(PWM_base)).
I am aware that jitter can occur when there is a sync event or when the time base period is changed, but in my case there is neither. (At least I think I have disabled all sync events).

Please find below a minimal example where I tried to realize a HRPWM with 2.10 MHz. I used the up-down-count mode and set the output pins when the counter equals CMPA. To generate an accurate PWM signal, enabled High Resolution for CMPA (MEP controls both rising and falling edges) as well as High Resolution Period with automatic HRMSTEP scaling. I took a screenshot with my oscilloscope showing the jitter.

Measuring the time deviation of the jitter gives a delta t of 10 ns, which is exactly the clock of the C2000 used. So it seems to me that the HRPWM is not working at all.

Additionally I noticed that the jitter only occurs, when the HR period control is enabled - independent of the CMPAHR.

Many thanks!

### Code: ###

main.c:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// main.c
#include "board.h"
void main(void)
{
// Device Initialization
Device_init();
Board_init();
while(1)
{
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

autogenerated board.h:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Copyright (c) 2020 Texas Instruments Incorporated - http://www.ti.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

autogenerated board.c:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Copyright (c) 2020 Texas Instruments Incorporated - http://www.ti.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Syscfg-File:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
* @cliArgs --device "F28004x" --package "F28004x_100PZ" --part "F28004x_100PZ" --product "C2000WARE@4.01.00.00"
* @versions {"tool":"1.14.0+2667"}
*/
/**
* Import the modules used in this configuration.
*/
const epwm = scripting.addModule("/driverlib/epwm.js");
const epwm1 = epwm.addInstance();
const sync = scripting.addModule("/driverlib/sync.js");
/**
* Write custom configuration values to the imported modules.
*/
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm1.epwmTimebase_syncOutPulseMode = "EPWM_SYNC_OUT_PULSE_DISABLED";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_shadowMode = true;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Jonathan,

    Thank you for posting your question. I'll need some time to look through your configuration. I'll respond by tomorrow.

    Best Regards,

    Marlyn

  • Hi Jonathan,

    I see that in your main.c you are not using the SFO library. Can you please try the example below?

    C:\ti\c2000\C2000Ware_version\driverlib\f28004x\examples\hrpwm\hrpwm_ex3_prd_updown_sfo.c

    Best Regards,

    Marlyn

  • Hi Marlyn,

    Thanks for your reply. I was able to partially suppress the jitter using the SFO library (as in hrpwm_ex3_prd_updown_sfo.c): The output of the ePWM1A (yellow signal in the screenshot) does not jitter anymore. However, ePWM1B (blue signal) still jitters, but with a slightly different pattern than last time.

    I generate the ePWM1B signal using dead-band configurations. So I set epwmDeadband_polarityFED to EPWM_DB_POLARITY_ACTIVE_LOW.

    If I use CMPB in combination with action qualifiers instead, I don't have the jitter problem anymore. But in fact, the CMPB approach would cost more time for run-time calculations in my project, so it is not an alternative.

    I varied the options a bit and found out that changing the epwmDeadband_polarityFED parameter has no effect on the jitter (see the following screenshot). The jitter only disappears when I disable the deadband completely.

    I also thought about setting hrpwm_edgeModeDB to HRPWM_DB_MEP_CTRL_RED_FED, but this has no positive effect either.

    Best regards,
    Jonathan

    main.c:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    // Includes
    #include "board.h"
    #include "SFO_V8.h"
    // Globals
    uint16_t status = SFO_INCOMPLETE;
    int MEP_ScaleFactor; // Global variable used by the SFO library
    volatile uint32_t ePWM[] = {0, PWM_BASE}; // only using one PWM instance
    // Function Prototypes
    void error(void);
    void main(void)
    {
    // autogenerated init functions
    Device_init();
    Device_initGPIO();
    Interrupt_initModule();
    Interrupt_initVectorTable();
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    .syscfg-file:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /**
    * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
    * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
    * @cliArgs --device "F28004x" --package "F28004x_100PZ" --part "F28004x_100PZ" --context "system" --product "C2000WARE@4.02.00.00"
    * @versions {"tool":"1.14.0+2667"}
    */
    /**
    * Import the modules used in this configuration.
    */
    const epwm = scripting.addModule("/driverlib/epwm.js", {}, false);
    const epwm1 = epwm.addInstance();
    const inputxbar = scripting.addModule("/driverlib/inputxbar.js", {}, false);
    const inputxbar1 = inputxbar.addInstance();
    const inputxbar_input = scripting.addModule("/driverlib/inputxbar_input.js");
    const inputxbar_input1 = inputxbar_input.addInstance();
    const inputxbar_input2 = inputxbar_input.addInstance();
    /**
    * Write custom configuration values to the imported modules.
    */
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Jonathan,

    I loaded your file into SysConfig, and saw that there is a warning with the way you've setup the HRPWM. Can you please correct this and see if this helps remove the jitter on your B channel?

    You can enable warnings through the 'Global Parameters' at the top of the EPWM module:

    Best Regards,

    Marlyn

  • Hi Marlyn,

    Thank you for your reply. I have changed the configurations as described in the warnings. Again, the jitter looks different now, but I'm not getting rid of it on channel B.

    How do I need to configure my PWM to use the HR period control in combination with the deadband module? Do I have to configure the SFO library in a special way?

    My main.c file remains unchanged this time, see my .syscfg file below.

    Best regards,
    Jonathan

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /**
    * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
    * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
    * @cliArgs --device "F28004x" --package "F28004x_100PZ" --part "F28004x_100PZ" --context "system" --product "C2000WARE@4.02.00.00"
    * @versions {"tool":"1.14.0+2667"}
    */
    /**
    * Import the modules used in this configuration.
    */
    const epwm = scripting.addModule("/driverlib/epwm.js");
    const epwm1 = epwm.addInstance();
    const inputxbar = scripting.addModule("/driverlib/inputxbar.js", {}, false);
    const inputxbar1 = inputxbar.addInstance();
    /**
    * Write custom configuration values to the imported modules.
    */
    epwm.enableWarning = true;
    epwm.enableInfo = true;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Jonathan,

    How do I need to configure my PWM to use the HR period control in combination with the deadband module? Do I have to configure the SFO library in a special way?

    Thanks for addressing the warnings. No, you shouldn't have to do that.

    I see that you are writing a value for CMPAHR, can you please write it for CMPBHR as well:
    epwm1.hrpwm_cmpbHR = 230;

    Here is a relevant thread that explains a bit more: https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1002939/c2000ware-do-you-need-to-program-cmpb-and-cmpbhr-if-using-active-high-complimentary-mode 

    Best Regards,

    Marlyn

  • Hi Marlyn,
    This worked. The jitter is now completely gone. (Although, to be honest, this last procedure does not seem very intuitive to me).
    Anyway, thanks for the support!
    Best regards
    Jonathan