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.

Can't connect COMP1out to TZ module

Other Parts Discussed in Thread: CONTROLSUITE

Context: I'm using a Piccolo 28023. I'm using EPWM2A and EPWM1A as a PWM outputs and I'm using DCAEVT1 of both to control those outputs.

The problem:

I configured COMP1A pin to protect both EPWM2A and EPWM1A outputs. I've configured COMP1 and 

I tested Comp1Regs.COMPSTS.bit.COMPSTS and COMP1 is working. (I swith voltage at COMP1A pin and COMPSTS changes accordingly)

Than "I connected" COMP1 output to module TZ:

EPwm2Regs.DCTRIPSEL.all = 0x0080;  

            //  DCALCOMPSEL = COMP1out;  and DCAHCOMPSEL = !TZ1 input

Then connected DCAL to DCAEVT2 using TZDCSEL:

EPwm2Regs.TZDCSEL.all = 0x0022; 
// 0000 xxxx xxxx xxxx = bits 15-12, not used
// xxxx 000x xxxx xxxx = bits 11-9 (3 bits) = DCBEVT2 , 000 = not used
// xxxx xxx0 00xx xxxx = bits 8-6 (3 bits) = DCBEVT1 , 000 = not used
// xxxx xxxx xx10 0xxx = bits 5-3 (3 bits) = DCAEVT2 , 100 => DCAEVT2 = DCAL high
// xxxx xxxx xxxx x010 = bits 2-0 (3 bits) = DCAEVT1 , 010 => DCAEVT1 = DCAH high
 // So DCAEVT2 should be 1 when COMP1 is 1.

Then connected DACEVT2 to DCAEVT2.force:
 EPwm2Regs.DCACTL.all = 0x0008; 
 // xxxx xx0x xxxx xxxx = bit 9 = EVT2FRCSYNCSEL , DCAEVT2 Force Synchronization
 // 0 Source Is Synchronous Signal
// 1 Source Is Asynchronous Signal
// (0, source is sync signal)
// xxxx xxx0 xxxx xxxx = bit 8 = EVT2SRCSEL, DCAEVT2 Source Signal Select
// 0 Source Is DCAEVT2 Signal
// 1 Source Is DCEVTFILT Signal
// (0, no filter, DCAEVT2.force = DCAEVT2 in)

First problem here:

TZFLG[DCAEVT2] does not receive nothing. Signal of COMP1 does not arrive here.

Finally connecting DCAEVT2.force to TZ:

EPwm2Regs.TZCTL.all  & 0x0FFF) != DISK_0x0F7D;

// 0000 1111 0111 1101 - 0x0F7D
// 0000 .... .... .... - unused
// .... 11.. .... .... - (11): DCBEVT2 do nothing
// .... ..11 .... .... - (11): DCBEVT1 do nothing
// .... .... 01.. .... - (01): DCAEVT2 provoques EPWM2A = 1 (IGBT turn off)
// .... .... ..11 .... - (11): DCAEVT1 do nothing
// .... .... .... 11.. - (11): TZB do nothing
// .... .... .... ..01 - (01): TZA provoques EPWM2A = 1 (IGBT turn off)

This does not work because signal never arrives to TZFLG[DCAEVT2].

I rechecked my code and I can't figure out why TZFLG[DCAEVT2] does not receive anything. Always 0.
I think I've interpreted something wrongly.

Any help is appreciated.
  • Hi Emanuel,

    Have you taken a look at the epwm_dcevent_trip_comp example in controlSUITE?  I think this does exactly what you're looking to do.  I would recommend taking a look at it.  Here is the comparator trip initialization from the example:

       // Define an event (DCAEVT1) based on TZ1 and TZ2
    EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP1OUT (0x8); // DCAH = Comparator 1 output
    EPwm1Regs.DCTRIPSEL.bit.DCALCOMPSEL = DC_TZ2 (0x1); // DCAL = TZ2
    EPwm1Regs.TZDCSEL.bit.DCAEVT1 = TZ_DCAH_LOW (0x1); // DCAEVT1 = DCAH low(will become active as Comparator output goes low)
    EPwm1Regs.DCACTL.bit.EVT1SRCSEL = DC_EVT1 (0x0); // DCAEVT1 = DCAEVT1 (not filtered)
    EPwm1Regs.DCACTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC (0x1); // Take async path

    EPwm1Regs.DCTRIPSEL.bit.
    // Define an event (DCBEVT1) based on TZ1 and TZ2
    EPwm1Regs.DCTRIPSEL.bit.DCBHCOMPSEL = DC_COMP1OUT (0x8); // DCBH = Comparator 1 output
    EPwm1Regs.DCTRIPSEL.bit.DCBLCOMPSEL = DC_TZ2 (0x1); // DCAL = TZ2
    EPwm1Regs.TZDCSEL.bit.DCBEVT1 = TZ_DCBH_LOW (0x1); // DCBEVT1 = (will become active as Comparator output goes low)
    EPwm1Regs.DCBCTL.bit.EVT1SRCSEL = DC_EVT1 (0x0); // DCBEVT1 = DCBEVT1 (not filtered)
    EPwm1Regs.DCBCTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC (0x1); // Take async path

    // Enable DCAEVT1 and DCBEVT1 are one shot trip sources
    // Note: DCxEVT1 events can be defined as one-shot.
    // DCxEVT2 events can be defined as cycle-by-cycle.
    EPwm1Regs.TZSEL.bit.DCAEVT1 = 1;
    EPwm1Regs.TZSEL.bit.DCBEVT1 = 1;

    // What do we want the DCAEVT1 and DCBEVT1 events to do?
    // DCAEVTx events can force EPWMxA
    // DCBEVTx events can force EPWMxB
    EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_HI (0x1); // EPWM1A will go high
    EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_LO (0x2); // EPWM1B will go low
    
    
    I added all of the hex values that the #defines are setting the register to after each name.  Go ahead and modify the registers to do the behavior you would like and see if this helps.  It looks like you may have been missing a few key registers.
    Kris
  • Hmm looks like that may have been cut off .. let's try again;

    I added all of the hex values that the #defines are setting the register to after each name.  Go ahead and modify the registers to do the behavior you would like and see if this helps.  It looks like you may have been missing a few key registers.

  • Hi Kris Parrent,

      I changed the code to connect COMP1 --> DCBEVT1.force --> OST --> TZA. I made several changes in my code, I've made lots of reconfig places ...

      I followed your suggestion, as in "controlSUITE", beacuse it was a tested code.

      Thinks started to work, COMP1 stopped EPWMxA only in some situations. I found out and EALLOW out of place. I had to check step by to step when OST bit "activates" was already in another place, but, in the other place EALLOW was not  configured.

      So, now It's working 100%.

      I do not intend to go bak to recheck the problem, because I made a lot of changes,but I have to admit that the problem could be a missing EALLOW before a write to TZDCSEL.

      Thanks Kris