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.

Piccolo : ISR2:EPWM4_TZINT(Comparator 2 & DAC)

Other Parts Discussed in Thread: TMS320F28027

Hello:

I would like an ISR to trigger every time my comparator output goes above a certain voltage. In effect my program will be doing what it is doing, either in an interrupt(INT3) or in the background, and then trigger an asynchronous interrupt(INT2) to run a few calculations and jump back to whatever it was just doing.

Microcontroller:

TMS320F28027 Piccolo

Comp2A

InputA: local Comp2A enable

Inverting pin: DAC set to 512(voltage goes above 1.5V then TZtrip)

TZ_PWM

Initialized PWM4 to 313Hz

ePWM4 Digital Compare bit connected to Comp2out

Async

Set Digital Compare Event 2 to trigger TZ interrupt

ISR_PWM

PieVector ePwm4_TZINT mapped to my specific ISR

Enable ISRs (EINT ERTM)

Specific ISR

Calculations

Clear Interrupt flags

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

My lab test set up:

TMS320F28027 Piccolo TI Dev board

Signal generator 3.2V sine wave output connected to ADCA4 pin (Comp2A)

Oscilloscope

What works:

ADCA4 is working properly

COMP2OUT signal (GPIO34pin) is triggering properly off of signal generator

What does NOT work:

CPU never breaks to Specific ISR routine

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I hope my intent is clear as outlined above. I read the documentation on ePWM, ISRs, and studied the examples provided by TI, specifically ePWMTrip.c and TripComp.c in the TIsuite as I was unable to find a specific ePWM TZ Trip using the Digital Compare register example.

Thank you for your time!

  • If you look the ePWM documentation (Digital Compare  Submodule) you can find that, if you want an interrupt generated you will have to use the synchronous path. The Async path is used to force the PWM pins to certain state.

    As an example:

    EPwm4Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP2OUT;
    EPwm4Regs.TZDCSEL.bit.DCAEVT2 = TZ_DCAH_HI;
    EPwm4Regs.DCACTL.bit.EVT2SRCSEL = DC_EVT2;
    EPwm4Regs.DCACTL.bit.EVT2FRCSYNCSEL = DC_EVT_SYNC;
    EPwm4Regs.TZEINT.bit.DCAEVT2 = TRUE;
    EPwm4Regs.TZCTL.bit.DCAEVT2 = TZ_NO_CHANGE;

     

     

  • Thanks for getting back to me, the code I used to get this to work is below. However, I am now noticing that the interrupt triggers the whole time the comparator is high, as opposed to just tripping on a rising edge or falling edge. Right now I am trying to just trigger on the rising edge, if you have any ideas on how to do this (without using the event filter) please let me know. Not that I am opposed to using the event filter just looking to be a little more creative. Thanks again for getting back to me.

     

    EPwm4Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP2OUT;   // DCAH = Comparator 2 output       

                EPwm4Regs.TZDCSEL.bit.DCAEVT2 =  TZ_DCAH_HI; // DCAEVT2 =  DCAH high(will become active as Comparator output goes high)   

                EPwm4Regs.DCACTL.bit.EVT2SRCSEL = DC_EVT2;           // DCAEVT2 = DCAEVT2 (not filtered)

                EPwm4Regs.DCACTL.bit.EVT2FRCSYNCSEL = DC_EVT_ASYNC;  // Take async path

                // Enable cycle by cycle TZ interrupt on DCAEVT2 event

                EPwm4Regs.TZCTL.bit.DCAEVT2 = TZ_FORCE_HI; // Force to High State Tripped

    EPwm4Regs.TZSEL.bit.DCAEVT2 = 0x0000; 

                EPwm4Regs.TZEINT.bit.DCAEVT2 = 1;

  • I don't think you can get only the rising edge because the comparator is meant for cycle-by-cycle control so then you wouldn't get any more signals if it were only edge sensitive and not level sensitive.

     

    JHi

  • Hi Paul,

    Did you figure out a solution for this problem? I am struggling at the same point...

    Thanks and BR

    Andreas

  • Hi Andreas,

    I posted this on behalf of a customer of mine.  They did get this figured out, but I'm not sure what their resolution was.  Sorry.

    Best regards,

    Paul

  • Hi Paul,

    Thanks for your answer. For the sake of the forum would it be possible to post their solution, I would be very grateful!

    BR Andreas