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.

TMS320F28377S: How to force a pwm state based on comparator output

Part Number: TMS320F28377S

Hi,

I've been playing with CMPSS and EPWM module for a while and I would like to push what I'm doing a bit further.The goal is something similar to peak current mode operation.

Here's what I would like to achieve :

I have two signals connected to two CMPSS. CompH and CompL are used on both CMPSS to do bipolar comparison of these two signals. When one of the compH goes high, I'd like PWM1A to be forced low and if both compH are low, I'd like PWM1 to continue it's normal operation. When one of the compL goes High, I'd like PWM1A to be forced High and if both compL are low, I'd like PWM1 to continue it's normal operation.

Here's what I did for now :

Cmpss1 and Cmpss2 config:

CompHINV = 0

CTRIPHSEL = 0 (async output sent to epwmXBar)

CompLINV = 1

CTRIPLSEL = 0 (async output sent to epwmXBar)

Xbar config to connect comparators to pwm module

EPwmXbar.TRIP4.Mux0 = 0 (Comp1 CTRIPH connected to Trip4)

EPwmXbar.TRIP5.Mux1 = 0 (Comp1 CTRIPL connected to Trip5)

EPwmXbar.TRIP4.Mux2 = 0 (Comp2 CTRIPH connected to Trip4)

EPwmXbar.TRIP5.Mux3 = 0 (Comp2 CTRIPL connected to Trip5)

PWM config

DCTRIPSEL.DCAHCOMPSEL = 3 //Digital compare High is connected to TRIP4

DCTRIPSEL.DCALCOMPSEL = 4 //Digital compare Low is connected to TRIP5

TZDCSEL.DCAEVT1 = TZ_DCAH_HI; //Generate event 1 on DCAH == 1)

TZDCSEL.DCAEVT2 = TZ_DCAL_HI; //Generate event 2 on DCAL == 1)

DCACTL.EVT1SRCSEL = DC_EVT1; //Use DCAEVT1 to generate event 1 event

DCACTL.EVT1FRCSYNCSEL = DC_EVT_ASYNC; Use async signal

DCACTL.EVT2SRCSEL = DC_EVT2; //Use DCAEVT2 to generate event 2 event

DCACTL.EVT2FRCSYNCSEL = DC_EVT_ASYNC; Use async signal

TZCTL.DCAEVT1 = TZ_FORCE_LO; //Force low when compH is high

TZCTL.DCAEVT1 = TZ_FORCE_HI; //Force high when compL is high

DCFCTL.BLANKE = 0; //No blanking enabled

That's pretty much it. I haven't been able to see this working yet. I'm not sure that when the comparator output will go low if the PWM will go back to its normal state of operation (listen to duty cycle compare) or if it will be forced in the associated DCAEVTx action. The more I read the datasheet, the more I understand that this will be like a one time forced trip zone. Other piece of information, I never control PWMxB. It is automatically managed by the dead band sub module.

If anyone has insight on this, if it's doable or anything it will be appreciated! 

  • Hello,

    One thing that jumps out at me to begin with is I don't see the mux's being enabled anywhere in the EPWM X-Bar.  Take a look at Figure 7-2 of the TRM found here:

    Note that each mux has an individual TRIPxMUXENABLE bit to allow the signal to propagate.  If that has already been done, can you copy and paste your actual configuration code for the EPWM and the EPWM-XBAR?  Have you already verified your comparators are in the expected state?

    Regards,

    Kris

  • Hi Kris,

    Sorry about that. I omitted those lines by mistake.

    I have

    EPwmXbarRegs.TRIP4MUXENABLE.MUX0 = 1;

    EPwmXbarRegs.TRIP5MUXENABLE.MUX1 = 1;

    EPwmXbarRegs.TRIP4MUXENABLE.MUX2 = 1;

    EPwmXbarRegs.TRIP5MUXENABLE.MUX3 = 1;

    I can confirm that the comparator "works" as expected and that they trigger a xbar event but on the PWM end, I'm not sure it's doing what I want. I could strip my code to send the exact configuration but it will take a little while. For now, it was especially to see if it was doable or if I've misunderstood how the DCEVT works. I notived there was a difference between EVT1 and EVT2 with OST vs CBC event types...

    Thanks