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 input pin going HIGH after being enabled

Hi! I am working on a Piccolo ControlStick (F28069). Currently I am trying to set up the comparator for using it in current-mode control of a power converter -- in principle a buck, but it could be used for other topologies.

On a first approach, I tried to trip the PWM based on the analog comparator connected to an external source (max. 3V); in spite of starting the program with 0 V, the PWM outputs were forced by the trip zone. After re-reading the PWM reference manual, some other posts on this forum, and re-writing my code, I have realized that the comparator input pin is being set to high after I enable it.

In fact, my program currently reads:

void main (void)
{
   InitSysCtrl (); /* initializes peripheral clocks and PLL */
   EALLOW;
   GpioCtrlRegs.AIOMUX1.bit.AIO2 = 0x3; /* disable AIO to use COMP -- this line does not change anything! */

   Comp1Regs.COMPCTL.bit.COMPDACEN = 1;
   EDIS;
   EINT; /* enable master interrupt */
   for (;;)
   {
   }
}

I have also checked the comparator pin of the stick with a working program (whose source code is not provided) and its associated board, and it did work. But if this program is run without board, the pin is set again to high. If I set the voltage at the pin, it already trips the PWM outputs -- this means, everything happens inside the microcontroller.

My question is, why is this "input" pin set high? Do I have to set up the comparator registers in a concrete sequence?

Thank you very much in advance.

  • Hi Alejandro,

    By default, the inverting input of the comparator is connected to the internal 10-bit DAC. Try setting the DAC to max code=1023 with low non-inverting input voltage and see if the comparator still trips.

  • Hi Frank,

    Thank you for your reply. I have set the DACVAL register to 1023, and removed the code for the setup of the trip zone (TZDCSEL, etc. registers -- just to remove possible causes). A 0,2 V voltage was connected to the COMP1A-But this issue is already present.

    It takes about 300 ms since the comparator is enabled (COMPDACEN = 1, all other registers are already set up) until the COMPSTS bit is set to 1 -- what actually would carry out the trip action, if enabled. I have tried using the other comparator modules of the same microcontroller, and another microcontroller (also a F28069), with exactly the same results.

    I am not sure whether this means that something is going wrong within the microcontroller (an infra-red camera showed that there are no hot spots on the package), or I only need some extra hardware or configuration to avoid glitches.

    EDIT:

    I have found the origin of the issue. The bandgap of the ADC was enabled in its corresponding software module, which was commented out for this part of the project. So I will add the corresponding lines to enable it in the COMP- software module, I hope this redundancy does not hurt.

    However I did not expect that the comparator input would go High -- and thus behave as an output pin.

    Thank you anyway for your help.

  • Alejandro,

    The comparator input hysteresis on F2806x is implemented with a Schmitt trigger that will introduce pull current on the input pin. That is probably why your input appears to seek High and Low.

    -Tommy
  • Piccolo 28027
    I have the same problem (COMP1A was pulled to High). The solve is to turn off hysteresis - AdcRegs.COMPHYSCTL.bit.COMP1_HYST_DYSABLE = 1;
  • Hi Rustam,

    Thanks for sharing that this solution also works on F28027. I think this should actually apply to comparators on all F2802x, F2803x, F2806x, F2805x, and F28M3x devices.