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.

CCS/TMS320F28054F: Over current protection using CTRIP, ePWM TZ

Part Number: TMS320F28054F

Tool/software: Code Composer Studio

I'm trying to use my 3 current sensing ADC inputs (A1, A3, B1) to implement over current protection (shut down the PWM when current gets too high). I want to use CTRIPM1 as the input to the digital compare submodule, and from there generate a trip in TZ and set all of the ePWM signals low. I can force a trip and cause the pwm to shut off successfully, but cannot generate one from the analog comparators at the ADC pins. Information seems to be pretty scattered on this topic, so any help is appreciated. Thanks.

Here's my relevant code (only working on ePWM 1 right now for simplicity's sake):

    AnalogSubsysRegs.ADCINSWITCH.bit.ADCINA1SEL = 0;    //Set switch to connect A1 to A1
    AnalogSubsysRegs.ADCINSWITCH.bit.ADCINB1SEL = 0;    //Set switch to connect B1 to B1

    AnalogSubsysRegs.PGAEN.bit.AMPA1EN = 1; // Enable gain amplifier on A1
    AnalogSubsysRegs.PGAEN.bit.AMPA3EN = 1; // Enable gain amplifier on A3
    AnalogSubsysRegs.PGAEN.bit.AMPB1EN = 1; // Enable gain amplifier on B1

    AnalogSubsysRegs.AMPM1_GAIN.all = 0; // Set gain amplifier on A1, A3, B1 (gain of 3 = 0, 6 = 1, 11 = 2)

    // Settings for DAC
    AnalogSubsysRegs.DACEN.bit.DAC1EN = 1;      // enable DAC
    AnalogSubsysRegs.DAC1CTL.bit.DACVAL = 32;   // 6-bit (/64)

    // Settings for analog comparator
    AnalogSubsysRegs.COMPEN.bit.COMPA1EN = 1;
    AnalogSubsysRegs.COMPEN.bit.COMPA3EN = 1;
    AnalogSubsysRegs.COMPEN.bit.COMPB1EN = 1;

    // CTRIP
    AnalogSubsysRegs.CTRIPA1ICTL.bit.COMPHINPEN = 1;
    AnalogSubsysRegs.CTRIPA1ICTL.bit.COMPLINPEN = 1;
    AnalogSubsysRegs.CTRIPA3ICTL.bit.COMPHINPEN = 1;
    AnalogSubsysRegs.CTRIPA3ICTL.bit.COMPLINPEN = 1;
    AnalogSubsysRegs.CTRIPB1ICTL.bit.COMPHINPEN = 1;
    AnalogSubsysRegs.CTRIPB1ICTL.bit.COMPLINPEN = 1;

    AnalogSubsysRegs.CTRIPM1OCTL.bit.CTRIPA1EN = 1;
    AnalogSubsysRegs.CTRIPM1OCTL.bit.CTRIPA3EN = 1;
    AnalogSubsysRegs.CTRIPM1OCTL.bit.CTRIPB1EN = 1;

    // Settings for trip zone
    EPwm1Regs.TZSEL.bit.DCAEVT1 = 1; // enable DC event trip
    EPwm1Regs.TZSEL.bit.DCBEVT1 = 1;

    EPwm1Regs.TZCTL.bit.DCAEVT1 = 2; // set low on trip
    EPwm1Regs.TZCTL.bit.DCBEVT1 = 2;

    EPwm1Regs.TZEINT.bit.DCAEVT1 = 1; // enable DC force in TZ
    EPwm1Regs.TZEINT.bit.DCBEVT1 = 1;

    EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 8; // CTRIPM1 input
    EPwm1Regs.DCTRIPSEL.bit.DCALCOMPSEL = 8;
    EPwm1Regs.DCTRIPSEL.bit.DCBHCOMPSEL = 8;
    EPwm1Regs.DCTRIPSEL.bit.DCBLCOMPSEL = 8;

    EPwm1Regs.DCACTL.bit.EVT1SRCSEL = 1;    // filtered
    EPwm1Regs.DCACTL.bit.EVT1FRCSYNCSEL = 1; // asynch
    EPwm1Regs.DCBCTL.bit.EVT1SRCSEL = 1;
    EPwm1Regs.DCBCTL.bit.EVT1FRCSYNCSEL = 1;

  • Braden,

    I'd recommend enabling the CTRIPM1OUT path from the comparators to a GPIO pin (like GPIO12) so that you can directly observe the CTRIPM1 status using your desired configuration. This will help with debugging most comparator issues:

    Since you only have DAC1 configured, I would recommend disabling the COMPL path:

    And since you don't have the digital filters configured, I would recommend using the filter bypass path:

    -Tommy

  • Thanks, sorry I'm getting back late, this project was low priority for a while.

    I have things working now, but I have a question. Would I be able to use a digital compare result to set a GPIO pin low (in the same way that it trips the PWM)? I don't see it documented anywhere, but it would be useful in my implementation to do this as part of the same process.

    Thanks again

  • Braden,

    There's no way to directly "trip" a pin with hardware that is assigned to the GPIO MUX function.  If it's a static signal, you could assign it to EPWM or Comparator output like a a zero-crossing detector.  Another option would be to generate an EPWM interrupt when a DC condition is triggered and use the CPU or CLA to drive the GPIO low from the ISR or TASK.

    -Tommy