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.

UCD3138: Analog Comparator Interrupt Source

Part Number: UCD3138

Dear all,

I configured analog comparators for UV and OV protection. Analog comparators works properly. Also interrupts of a comparators were configured. During my tests, I observed PWM outputs and FAULTMUXINTSTAT and FAULTMUXRAWSTAT. When the fault occurs, PWMs are shut down. However, there is no change on FAULTMUXINTSTAT or FAULTMUXRAWSTAT. 

I know reading FAULTMUXINTSTAT clears that bit, therefore I thought that FAULTMUXINTSTAT register may not be observed for this reason. To overcome this problem, corresponding interrupt software in below is used:

#pragma INTERRUPT(standard_interrupt,IRQ)
void standard_interrupt(void)

{

if (CimRegs.IRQIVEC.all == 26)     //interrupt source is analog comparators.
{

D_T1 = 1;                      //Initialized as 0. If analog comparator interrupt occurs, D_T1 is 1

switch (fault_status)

{

case (No_Fault):

if(FaultMuxRegs.FAULTMUXINTSTAT.bit.ACOMP_B == 1 )             //If interrupt source is comp B, change fault_status as V1_OV
          fault_status = V1_OV;

else if(FaultMuxRegs.FAULTMUXINTSTAT.bit.ACOMP_C == 1 )             //If interrupt source is comp C, change fault_status as V1_UV
          fault_status = V1_UV;

}

}

D_T2 = fault_status;

}

In this interrupt routine, D_T1 is seen as 1 in the memory debugger but D_T2 variable does not change. I am sure there is no other analog comparators enabled. If there is another way to detect which comparator starts interrupt routine, I would be appreciated if you help me.

Thanks

Regards

Merih

  • Hi, Merih,

    Store the status of the register  FaultMuxRegs.FAULTMUXINTSTAT.all into an  intermediate variable. When you read this register, all flags are cleared. Later on, you use the intermediate variable for the comparison.

    Did you apply DC voltage or pulse voltage on the comparator input? If it is pulse voltage, the voltage can't be too short, at least 64ns. Also, make sure the comparator interrupt is enabled

    Regards,

    Sean

  • Hello Sean,

    Thank you for the suggestion. I will write back whenever I try it again.

    Regards,
    Merih