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.

Comparator TripZone



Hi,

I am using F28035 for my project.

I've configured the output of the comparator 3 to trigger a tripzone on ePWM6 when COMP3OUT is in the low state. It works fine, i saw the ewpm6 output change according to the COMP3OUT value.

The problem is that i use others interrupts including one to blink a led every 100ms using CPUTimer1 and when the COMP3OUT is in low state, the led stop blinking just like the interrupt did not happen. I don't understand why ...


Comparator and Epwm6 configuration :

EALLOW;
/* Configure comparator */
Comp3Regs.COMPCTL.bit.COMPDACEN = 1;            /* Power up Comparator 1 locally */
Comp3Regs.COMPCTL.bit.COMPSOURCE = 0;           /* Connect the inverting input to the internal DAC */
					
Comp3Regs.DACVAL.bit.DACVAL = 512;		/* Set DAC output to middle range */

/* Configure Epwm event when trip */
	
/* Define an event (DCAEVT1) based on DC_COMP3OUT */
EPwm6Regs.DCTRIPSEL.bit.DCALCOMPSEL = DC_COMP3OUT;      /** DCAL = Comparator 3 output */
EPwm6Regs.TZDCSEL.bit.DCAEVT1 = TZ_DCAL_LOW;            /** DCAEVT1 =  DCAL low (will become active as Comparator output goes low) */
EPwm6Regs.DCACTL.bit.EVT1SRCSEL = DC_EVT1;              /** DCAEVT1 = DCAEVT1 (not filtered) */
EPwm6Regs.DCACTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;		/** Take async path */

EPwm6Regs.TZSEL.bit.DCAEVT1 = 1;			/** DCAEVT1 events can force EPWM6A */
EPwm6Regs.TZCTL.bit.TZA = TZ_FORCE_HI;           	/**  EPWM6A will go high */

/** Enable TZ interrupt */
EPwm6Regs.TZEINT.bit.OST = 1;

/** Define an event (DCBEVT1) based on DC_COMP3OUT */
EPwm6Regs.DCTRIPSEL.bit.DCBHCOMPSEL = DC_COMP3OUT;      /** DCBL = Comparator 3 output */
EPwm6Regs.TZDCSEL.bit.DCBEVT1 = TZ_DCBH_LOW;            /** DCBEVT1 =  DCBL low (will become active as Comparator output goes low) */
EPwm6Regs.DCBCTL.bit.EVT1SRCSEL = DC_EVT1;              /** DCBEVT1 = DCBEVT1 (not filtered) */
EPwm6Regs.DCBCTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;     /** Take async path */

EPwm6Regs.TZSEL.bit.DCBEVT1 = 1;			/** DCBEVT1 events can force EPWM6B */
EPwm6Regs.TZCTL.bit.TZB= TZ_FORCE_HI;                   /** EPWM6B will go low */

/** Enable TZ interrupt */
EPwm6Regs.TZEINT.bit.OST = 1;

epwm6_isr :

interrupt void Epwm6Tripzone
(
	void
)
{
   EPwm6TZIntCount++;

   EALLOW;
   EPwm6Regs.TZCLR.bit.OST = 1; /** One Shot trip */
   EPwm6Regs.TZCLR.bit.INT = 1; /** Clear Tripzone Interrupt */
   EDIS;

PieCtrlRegs.PIEACK.all = 0x03; /** Issue PIE ACK */
}

cpuTimer1 isr :

 

interrupt void Timer1Tasks
(
	void
)
{
   EALLOW;
   CpuTimer1.InterruptCount++;
   EDIS;
   Blinkled();

}


setupInterrupt:

void setupInterrupts
(
	void
)
{

  EALLOW;

  /* CPU Timer interrupt */
  PieVectTable.TINT1 = &Timer1Tasks;
  PieVectTable.TINT2 = &Timer2Tasks;

  /* Trip Zone interrupt */
  PieVectTable.EPWM6_TZINT = &Epwm6Tripzone;
  PieCtrlRegs.PIEIER2.bit.INTx6 = 1;

  /* SPI interrupt */
  PieVectTable.EPWM1_INT = &Spi;    /** Map Interrupt */
  PieCtrlRegs.PIEIER3.bit.INTx1 = 1u;         /** PIE level enable, Grp3 / Int1 */
  EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO;   /** INT on PRD event */
  EPwm1Regs.ETSEL.bit.INTEN = 1u;             /** Enable INT */
  EPwm1Regs.ETPS.bit.INTPRD = ET_3RD;         /** Generate INT on every 3 event */

  /* calcul interrupt */
  PieVectTable.EPWM2_INT = &calcul;      	/** Map Interrupt */
  PieCtrlRegs.PIEIER3.bit.INTx2 = 1u;      	/** PIE level enable, Grp3 / Int2 */
  EPwm2Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO;    /** INT on PRD event */
  EPwm2Regs.ETSEL.bit.INTEN = 1u;              /** Enable INT */
  EPwm2Regs.ETPS.bit.INTPRD = ET_3RD;         /** Generate INT on every event */

  IER |= M_INT2;						/** Enable CPU INT2 connected to EPWM1-6 XINTs */
  IER |= M_INT3 ;                     /** Enable CPU INT3 connected to EPWM1-6 INTs */
  IER |= M_INT13;		      /** Enable CPU INT13 connected to CPU_Timer_1 */
  IER |= M_INT14;		      /** Enable CPU INT14 connected to CPU_Timer_2 */
  EINT;                               /** Enable Global interrupt INTM */
  ERTM;                               /** Enable Global realtime interrupt DBGM */
  EDIS;
}

I guess it's a problem of interruptions or maybe tripzone event configuration but I can not find  where the problem is ..

Thanks,

Stanis

 

  • Hi Stanis,

    If the input to COMP3 is changed back to the 'good' state (after a trip state condition), does the LED start blinking again? 

    If so:  As long as the fail condition continues to occur, perhaps all the CPU's cycles are being used to run code in consecutive trip zone interrupts.


    Thank you,
    Brett

  • Hi Brett,

    Thank you for your reply.

    Yes, after a trip state condition, the led start blinking again ...

    I think this is something like that, but i don't know how to solve the problem ... is it possible to trigger an event only once each time the comparator output is low state ?


    Thank you


    Stanis

  • Hi Stanis,

    Well the question is, what do you want to happen?  Right now, it's doing what it is coded to do.  The PIE2 interrupt is higher priority than the other interrupts and the trip event is continually occurring.  It may be worth referring to the ePWM User Guide and System Control and Interrupts Guide for this device - to learn more and prove to yourself that its doing what it should.

    ===

    In many of the C2000 applications kit's software that we provide, we don't have the Trip Zone generate an interrupt.  Instead, we make the comparator event force the PWM to a safe state immediately.  We then poll the state of the trip and the state of the comparator as a 'background' task done in main().  Here we could then call additional routines to see if we should turn the PWMs back on - and do so in a controlled way. 

    Another option is to disable the next TZ interrupt inside the interrupt.

    Another option is to not ACK the TZ interrupt's PIE group until it was 'safe'.  This may have implications if there are more interrupts in this same PIE group.


    Thank you,
    Brett