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: Fault interrupt routine

Part Number: UCD3138

Hi,

I have been having difficulty setting up interrupts on the UCD3138 digital power controller. I am trying to set up a  Fault pin (Fault 2 pin) to trigger a fast interrupt. However, I have not been able to set up the fault to trigger in the FIQ interrupt routine.

My goal is to set up the Fault 2 pin to generate a gate driver interrupt routine, and shut down PWM's immediately. 

Can someone please help me with this issue?

Here's My code initialization ( I also have a PWM 2 interrupt set up)

GioRegs.FAULTIN.bit.FLT2_IN =0; //Set up Faul2 pin for Gate Driver Fault input
MiscAnalogRegs.GLBIOVAL.bit.FAULT2_IO_VALUE = 2;

FaultMuxRegs.EXTFAULTCTRL.bit.FAULT2_POL = 1; // Fault 2 Detected on falling Edge
FaultMuxRegs.EXTFAULTCTRL.bit.FAULT2_INT_EN = 1;
FaultMuxRegs.EXTFAULTCTRL.bit.FAULT2_DET_EN = 1; //FAULT[2] Pin Detection Enable

disable_interrupt();
disable_fast_interrupt(); //make sure fast interrupt is disabled
write_reqmask(CIMINT_ALL_DPWM2 | CIMINT_ALL_PWM2_COMP | CIMINT_ALL_FAULT_PIN); //enable pwm2cmp and DPWM0 interrupt(End of 16th period)(int-priority29)
write_firqpr (CIMINT_ALL_DPWM2 | CIMINT_ALL_FAULT_PIN); // DPWM0 interrupt(End of 16th period) is mapped to FIQ
enable_fast_interrupt();
enable_interrupt();

void fast_interrupt(void)
{

register int32 fiq_number, interrupt_bits;
fiq_number = CimRegs.FIQIVEC.all; // Clear on read
interrupt_bits = FaultMuxRegs.FAULTMUXINTSTAT.all; // Clear on read

/*
volatile Uint32 read_scrap;

*/

GateDriveFault = 1;


if(fiq_number == 30) // Fault Pin Interrupt
{
if(interrupt_bits & 0x400) // If FAULT2
{
MiscAnalogRegs.GLBIOEN.all |= 0xFF;
GateDriveFault = 1;z
}

}

  • If you want to stop the DPWM with the fault pin, you need to use the fault mux to link the fault pin to the DPWM. This will give you an essentially instantaneous shut off, with no firmware delays involved. You may just need to poll in the standard interrupt, since it will be shut off for you. If you use the hardware shutoff, we recommend that you use the DPWM fault bits for interrupt and/or for polling. Once in a great while, we see the DPWM getting shut off, with no latching of the corresponding FAULT mux interrupt bit. They are somewhat different logic chains, so the timing must have to be just right for one to catch it and the other one to miss it.

    To look at your code::

    1. GioRegs.FAULTIN.bit.FLT2_IN is a read only bit that shows the value on the pin
    2. MiscAnalogRegs.GLBIOVAL.bit.FAULT2_IO_VALUE is a register that controls the value on the FAULT 2 pin only if you enable it as a GLBIO pin, and make it an output. Don't do this, as you will have a tug of war with whatever you have trying to drive FAULT2 from outside.
    3. The defaults are correct for what you want to do as far as the GIO and GLBIO registers go. Leave them alone.
    4.FaultMuxRegs.EXTFAULTCTRL.bit.FAULT2_POL - setting it to a 1 actually means rising edge, not falling edge. This is the default
    5. Next 2 lines are good. Setting int_en and det_en
    6. it looks good after that until you get to the fast interrupt
    7. the FIQIVEC actually gives the number of the interrupt plus 1, so you need 31, rather than 30. 0 means no interrupt active
    8. Our documentation is wrong, the CIM registers, including FIQIVEC are not clear on read. But when you read the FAULTMUXINTSTAT, you should clear both.
    9. So I would expect that if you change the 30 to a 31, it should work the way you want it to.
    10. But to avoid rare intermittent failures, where the DPWM gets shut off, but the interrupt doesn't happen (and to get fast shut off), I suggest using the FAULT MUX to switch off the DPWM directly, and use the DPWM interrupt to respond.
  • Thank you very much, I finally got it to work...by checking the GioRegs.FAULTINTPEND.bit.FLT2_INT_PEND flag.
    I also set up the GPIO to generate a fault...so for anyone else having a hard time with this...here's my set up.

    //Set Up Fault 2 pin to generate a fault
    GioRegs.FAULTINTENA.bit.FLT2_INT_EN = 1;
    GioRegs.FAULTDIR.bit.FLT2_DIR = 0;
    GioRegs.FAULTIN.bit.FLT2_IN = 0; //1 - Fault pin must be driven High. 0 - Driven Low to trigger Interrupt
    GioRegs.FAULTINTPOL.bit.FLT2_INT_POL = 0; //Interrupt will be generated on 1 = Rising Edge, 0 = Falling Edge

    disable_interrupt();
    disable_fast_interrupt(); //make sure fast interrupt is disabled
    //write_reqmask(CIMINT_ALL_DPWM2 | CIMINT_ALL_PWM2_COMP); //enable pwm2cmp and DPWM0 interrupt(End of 16th period)(int-priority29)
    //write_firqpr (CIMINT_ALL_DPWM2); // DPWM0 interrupt(End of 16th period) is mapped to FIQ
    write_reqmask( CIMINT_ALL_DPWM2 | CIMINT_ALL_PWM2_COMP | CIMINT_ALL_FAULT_PIN); //enable pwm2cmp and DPWM0 interrupt(End of 16th period)(int-priority29)
    write_firqpr (CIMINT_ALL_DPWM2 | CIMINT_ALL_FAULT_PIN); // DPWM0 interrupt(End of 16th period) is mapped to FIQ
    enable_fast_interrupt();
    enable_interrupt();