Showing results for 
Search instead for 
Did you mean: 

STM32-L452RE comparator triggering in both edges

Associate II


I have been with a problem with the stm32l452 comparator for a few days now and I can't figure it out. The interrupt of COMP1 triggers on both edges rather than rising edge.

I tried differents configurations but main is the following:

hcomp1.Init.InvertingInput = COMP_INPUT_MINUS_IO1;

hcomp1.Init.NonInvertingInput = COMP_INPUT_PLUS_IO2;


hcomp1.Init.Hysteresis = COMP_HYSTERESIS_HIGH;

hcomp1.Init.BlankingSrce = COMP_BLANKINGSRC_NONE;


hcomp1.Init.WindowMode = COMP_WINDOWMODE_DISABLE;

hcomp1.Init.TriggerMode = COMP_TRIGGERMODE_IT_RISING;

The references for input minus is generated through 3.3V from nucleo board with a resistor divider of two resistor of 1M. The input plus signal is generated with a signal generator, square wave of 300Hz, 1.5V offset and 3Vpp.


1) In COMP1 ultra low power mode, COMP interrupt triggers twice as expected.

2) COMP in high speed mode: interrups apperas to trigger on rising edge (good), although COMP or COMP interrupt loses a few pulses per second. Checked this incrementing a counter in the interrupt and sending it through UART to PC.

3) I tried not triggering interrupt and just checking the value of the COMP output in the while(1) loop. Behavior is the same ...

4) External Vref on INM has a 100nF capacitor. Tried to remove it, and also tried to add capacitor in INP (difrerents values: 12pF - 333pF - 1nF). Behavior is the same ...

5) Tried Internal Vref, no changes.

I attached pictures of rising and falling edge in ultra low power mode of comparator.


YELLOW is INM (external reference)

PURPLE is comparator output

Any advice or something to check?

Thanks in advance for your time!

Best regards.

Associate II


I have a colleague that generated the input plus signal INP with the STM32L452RE itself.

He tried signals from 1Hz to 1kHz. He found weird behavior, in some combinations of power_mode and hysteréris it worked (barely) and in ther combinations it didn't worked (COMP interrupt was triggering where it not supposed to).