Skip to main content
Senior
Aug 30, 2022 9:53 PM UTC
Question

Avoid Interrupt after HAL_COMP_Start(&hcomp1)

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

SLivi.1
Associate II
Oct 4, 2024 4:44 PM UTC

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

waclawek.jan
Super User
Oct 4, 2024 5:19 PM UTC

Post details.

JW

SLivi.1
Associate II
Oct 4, 2024 5:56 PM UTC

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.

SLivi.1
Associate II
Oct 4, 2024 7:45 PM UTC

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