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 DCOMP problem

Hi,

this time I try to use a DCOMP.

EADC0 gets the Output voltage (divided) and is used to Close the control Loop. To prevent the unloaded flyback module from generating too high voltages, DCOMP0 should fire if the Limit is exeeded and stop the DPWM.

I followed the samples (Cyclone labs) and do this with ACOMP_F and AD06 Input. Works. But why using two Inputs for that function, DCOMP0 is the better solution, I thought.

Here my config:

void init_HW_OV_Protection_DComp(void)

{

FaultMuxRegs.DCOMPCTRL0.bit.FE_SEL = 0; // FrontEnd0, absolute data

FaultMuxRegs.DCOMPCTRL0.bit.COMP_POL = 1; // Fires if input is greater

FaultMuxRegs.DCOMPCTRL0.bit.THRESH = 500; //Threshold, 1.5625mV/bit 500 .. 781mV

FaultMuxRegs.DCOMPCTRL0.bit.CNT_THRESH = 2; // Observes CNT_THRESH values, max. 255

FaultMuxRegs.DCOMPCTRL0.bit.CNT_CONFIG = 0; // 0 .. good samples clear the counter, 1 .. good samples decrement the counter

FaultMuxRegs.DCOMPCTRL0.bit.INT_EN = 0; // Generate interrupts

FaultMuxRegs.DCOMPCTRL0.bit.COMP_EN = 1; // Enable comperator

FaultMuxRegs.DPWM0FAULTDET.bit.PWMA_DCOMP0_EN = 1; // Root DCOMP0 output to DPWM0A fault input.

}

Well, Interrupt is disabled, I know!!!

Now I check FaultMuxRegs.FAULTMUXRAWSTAT.bit.DCOMP0 and it was 0, after exeeding the Limit it is 1, perfect.

I also checked out the ..CNTSTAT and I get 0 or 2, perfect.

I toggled the CNT_CLR bit and this clears also  FaultMuxRegs.FAULTMUXRAWSTAT.bit.DCOMP0, perfect.

Now I enabled the Interrupt. After exeeding the Limit, the DPWM still running but the Debugger crashes. I have to restart the USB-to-GPIO box, and the Digital Fusuin GUI and Flash the program.

???

I also read the INTSTAT (

if ( FaultMuxRegs.FAULTMUXINTSTAT.bit.DCOMP0 == 1 ) ov_state ++; //OVP) as I have done with ACOMP_F before, nothing helps.

Whats wrong?

By the way. After implementing light load mode, ACOMP_F didn't stop the DPWM, but this behavior is under further Investigation.

Thanks a lot for helping.

With best regards

Gerhard

 

  • ... so, after playing around I get a 'workaround', or a hack, it is really not nice:

    #pragma INTERRUPT(standard_interrupt,IRQ)

    void standard_interrupt(void)

    {

    GioRegs.FAULTOUT.bit.FLT0_OUT = 1;

    // Just testing, DPWM modules stopped by hardware flag

    // if ( FaultMuxRegs.FAULTMUXINTSTAT.bit.ACOMP_F == 1) supply_state = SUPPLY_OV; //OVP (hardware)

    if ( FaultMuxRegs.FAULTMUXRAWSTAT.bit.DCOMP0 == 1 ) { ov_state ++; FaultMuxRegs.DCOMPCTRL0.bit.CNT_CLR = 1; FaultMuxRegs.DCOMPCTRL0.bit.CNT_CLR = 0; } //OVP (Hardware)

    .......

    }

    After exeeding the Limit, the Counter start counting and reaches his threshold. Now the  FaultMuxRegs.FAULTMUXRAWSTAT.bit.DCOMP0 bit is set.

    After lowering the Input voltage (factor 10) the Input clearly DON'T exeed the Limit, but the Counter isn't cleared automatically by Hardware or decremented (to Zero) automatically by HW. It is frozen and so the  FaultMuxRegs.FAULTMUXRAWSTAT.bit.DCOMP0 bit is set for infinite time. Hahah.

    In my regular timer Interrupt I test the  FaultMuxRegs.FAULTMUXRAWSTAT.bit.DCOMP0 bit and reset the Counter manually. If the over-limit condition is still there, the Counter Counts up and thats it. As soon as the error condition is removed however, the Counter is cleared, the  FaultMuxRegs.FAULTMUXRAWSTAT.bit.DCOMP0 bit is cleared and the Counter remains Zero.

    English isn't my mothers language, but I think, this procedure isn't described in the Manual, isn't it. In the documentation there is stated: Counter is cleared or decremented if the over Limit condition isn't there ....

    I am wrong? Is thare any trick to get this working regular or is my 'work around' the solution??

    With best regards

     

    Gerhard

  • Hi Gerhard,

     

    What is the duration of the over voltage.  Did you map the DCOMP interrupt to an interrupt service routine?

    Thanks,

    Sanatan