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/UCD3138: AD04 Analog Comparator How to continue Entry fast interrupt

Part Number: UCD3138

Tool/software: Code Composer Studio

Hello;

I want to use   UCD3138  PIN AD04  Analog Comparator Entry fast interrupt.I set ACOMP_D_POL=1 and input voltage always highter than the ACOMP_D_THRESH. 

But the program can't stop in fast interrupt.lt just into fast interrupt once time,then it never occur.

I shuold make the input voltage lower than ACOMP_D_THRESH and higher again, entry the fast interrupt one time.

How make while the  input voltage always higher than the  ACOMP_D_THRESH always touch off  the fast interrupt .

Here are some of my code:

void init_AD04_F(void)
{
FaultMuxRegs.ACOMPCTRL0.bit.ACOMP_EN=1; 
FaultMuxRegs.ACOMPCTRL1.bit.ACOMP_D_SEL=0; 
FaultMuxRegs.ACOMPCTRL1.bit.ACOMP_D_INT_EN=1; 
FaultMuxRegs.ACOMPCTRL1.bit.ACOMP_D_POL=1; 
FaultMuxRegs.ACOMPCTRL1.bit.ACOMP_D_THRESH=127; 
write_firqpr(CIMINT_ALL_FAULT_MUX);
write_reqmask(CIMINT_ALL_FAULT_MUX);
enable_interrupt();
enable_fast_interrupt();
}

void fast_interrupt(void)
{

k = FaultMuxRegs.FAULTMUXINTSTAT.bit.ACOMP_D;

}

  • I'm not sure why you want to do this. Normally the fast interrupt is used to detect a fault condition, and then stop things quickly. And then normally you monitor the condition using the ADC and don't restart until it is below the limit. That is what I would suggest you do. Otherwise the program will just get stuck in the fast interrupt function and keep going back to it. Effectively the program will get locked up.

    The fast interrupt is edge sensitive, as you have found out. But I assume that the edge sensitive logic is after the initial logic. Certainly it is after the comparator. So if you want to keep retriggering it even if it stays high, you could probably just set the threshold to the maximum. Assuming your pin voltage is below the maximum threshold, that will provide a falling edge to reset the logic, and then you can set the threshold back to what you desire. Of course, if you do this in the fast interrupt, you will have the lock up that I described above.

    If you pin voltage is higher than the maximum comparator threshold, then you could reverse the polarity of the comparator interrupt, using the ACOMP_D_POL bit, and then clear the interrupt that will probably generate, and then put the polarity back to what you desire. Again, if you do that in the fast interrupt with the pin voltage still high, you will get stuck in the interrupt.

    I haven't tested either of these suggestions, but they should work.
  • Thank you for you suggestion.
    I wrote some text code with your suggestion.
    here are some of my code ,

    for(;;)
    {
    l++;
    FaultMuxRegs.ACOMPCTRL1.bit.ACOMP_D_POL=1;
    pmbus_handler();
    }

    void fast_interrupt(void)
    {
    j++;
    FaultMuxRegs.ACOMPCTRL1.bit.ACOMP_D_POL=0;
    k = FaultMuxRegs.FAULTMUXINTSTAT.bit.ACOMP_D;
    }

    Fast interrupt can be touched off repeatly.But the program will into Background loop too.
    I am not sure, I didn't misunderstand your point. If i did ,please correct me .

    And I try to add a Judging condition before clear the interrupt flag. It work. But as you said the program will locked up in the fast interrupt . But when the judging condition is true,clearing the flag, program will jump out from the interrupt.

    Here are my code:
    void fast_interrupt(void)
    {
    if(FaultMuxRegs.FAULTMUXRAWSTAT.bit.ACOMP_D == 0)
    {
    k = FaultMuxRegs.FAULTMUXINTSTAT.bit.ACOMP_D;
    }
    }

    I found ,when program into fast interrupt , the PMBUS can't work.Should I add pmbus_handler() function in interrupt ?
    I never found TI demo codes have add this function in fast interrupt.

    I am debugging happily.
  • If the PMBus doesn't work, that shows that the fast interrupt is taking most of the background time.  You definitely don't want to put the PMBus handler call in the fast interrupt.  Instead, make sure that the fast interrupt doesn't lock up.  Do what I recommended before - use the fast interrupt for fast response to whatever is coming in on AD04, and then monitor the pin with the ADC until it goes down again. 

    For the debugging exactly when the fast interrupt is happening, make an I/O line high when the interrupt starts, and then low again when the interrupt exits.

    It takes a while for the hardware and software to enter the fast interrupt and to exit it too, so the I/O line edges will not show the full time of the interrupt.