Skip to main content
Explorer II
August 30, 2022
Question

Avoid Interrupt after HAL_COMP_Start(&hcomp1)

  • August 30, 2022
  • 4 replies
  • 1521 views

I set a breakpoint inside the function:

void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp)

I got an interrupt event just after calling the function:

HAL_COMP_Start(&hcomp1);

I tried to pull-down/pull-up, I tried with all triggers modes but I ever get one false interrupt, how can I avoid it?

    This topic has been closed for replies.

    4 replies

    Visitor II
    October 4, 2024

    I realize this is an old post. But I am experiencing this issue on the STM32G0B1. I was wondering if you ever resolved this.

    Super User
    October 4, 2024

    Post details.

    JW

    Visitor II
    October 4, 2024

    Thank you for a quick response.

    I am using HAL code generated using STM32CubeIDE v. 14.0 for the STM32G0B1KEUxN.

    I have the comparator configured for a gpio pin Input positive and a dac output as the Input negative. Output polarity is set to invert because I want it to trigger when the gpio input goes below the threshold. I have the trigger mode set to rising edge interrupt.

    After setting the dac value with the comparator stopped, I call HAL_COMP_Start and get an immediate interrupt even though I know the gpio input is higher than the dac output.

    If I read via HAL_COMP_GetOutputLevel and compare that in my ISR, I see that it is not COMP_OUTPUT_LEVEL_HIGH.

    Please let me know if I can clarify anything else.

    Visitor II
    October 4, 2024

    Nevermind on this one. I think I ended up needing to not invert the output polarity and to trigger on falling edge.