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.

TMS320F28379D: Make complementary PWM signals

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Dear TI team,

In order to make complementary signals using ePWM modules, I used and modified the code section (from: C:\ti\c2000\C2000Ware_3_04_00_00\device_support\f2837xd\examples\cpu1\epwm_deadband\cpu01)

EPwm1Regs.TBPRD = 1000; // Set timer period
EPwm1Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
EPwm1Regs.TBCTR = 0x0000;

EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;//TB_COUNT_UP; // Counting mode
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading. #define TB_DISABLE 0x0
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; //TB_DIV1 = 0x0 -> Dividing for 1
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1; //TB_DIV1 = 0x0 -> Dividing for 1
//EPwm1Regs.PERCLKDIVSEL.bit.EPWMCLKDIV =

EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every ZERO
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;

//
// Setup compare
//
EPwm1Regs.CMPA.bit.CMPA = 750;

EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // Set EPWMxA high
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR; // Set EPWMxA low

// AQCTLB: Action Qualifier Control Register For Output B
EPwm1Regs.AQCTLB.bit.CAU = AQ_CLEAR; // Set EPWMxB low
EPwm1Regs.AQCTLB.bit.CAD = AQ_SET; // Set EPWMxB high

From the code section above, the EPWM1A and EPWM1B output signals should be complementary, is it correct? However, on my oscilloscope, the two signals are identical. 

My questions are:

(1) Is there any wrong with my code or my setup?

(2) What is the purpose of shadowing registers in the code below:

EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every ZERO
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;

Thank you very much for your help. Because I am a newbie to C2000, your guidance is very meaningful to me.

Regards,

  • Hi Van,

    VAN NGUYEN said:
    (1) Is there any wrong with my code or my setup?

    I don't see anything incorrect with the code you have above. Is this all you have for your initialization? If you have the dead-band submodule configured then this could be affecting your output since the dead-band submodule comes after the action qualifier submodule. 

    VAN NGUYEN said:
    (2) What is the purpose of shadowing registers in the code below:

    The shadow registers are used to load CMPA/CMPB registers at a certain event or instance defined by the LOADAMODE/LOADBMODE instead of taking effect immediately. The following section within the TRM explains this in a bit more detail: 'Operational Highlights for the Counter-Compare Submodule'

    Best Regards,

    Marlyn

  • Hi Marlyn,

    Thank you for your answer.

    Marlyn Rosales Castaneda20 said:
    I don't see anything incorrect with the code you have above. Is this all you have for your initialization? If you have the dead-band submodule configured then this could be affecting your output since the dead-band submodule comes after the action qualifier submodule.

    I see. In the dead-band submodule, there is an option to invert the signal, which is specified by POLSEL bit.

    Marlyn Rosales Castaneda20 said:
    The shadow registers are used to load CMPA/CMPB registers at a certain event or instance defined by the LOADAMODE/LOADBMODE instead of taking effect immediately. The following section within the TRM explains this in a bit more detail: 'Operational Highlights for the Counter-Compare Submodule'

    I read and see there is an explanation like this: "The counter-compare registers CMPA and CMPB each have an associated shadow register. Shadowing provides a way to keep updates to the registers synchronized with the hardware. When shadowing is used, updates to the active registers only occur at strategic points. This prevents corruption or spurious operation due to the register being asynchronously modified by software."

    I still don't understand the purpose of shadowing clearly. So in what circumstances we should use shadowing or not? When we should update the active registers as explained above?

    Thank you for your patience.

    Regards,

  • Hi Van,

    VAN NGUYEN said:
    I see. In the dead-band submodule, there is an option to invert the signal, which is specified by POLSEL bit.

    Yes! were you setting a POLSEL value?

    VAN NGUYEN said:
    So in what circumstances we should use shadowing or not? When we should update the active registers as explained above?

    This is highly dependent on your application and safety requirements. Shadow registers are recommended so that you avoid changing a critical value in your system at an unknown state. For example, if you change CMPA while not using shadow mode then you run the risk of skipping a CMPA event since you wouldn't know exactly where your counter is at when you change CMPA. If you do shadow loading you can choose to load the new value of CMPA when the counter is at zero, period, or both (meaning you know how the new CMPA change will affect your system). For other systems the design may call for an immediate change but most people use shadow loading to help prevent any issues in their output waveforms.

    Best Regards,

    Marlyn