I have an STM32F301, and plan to use the COMP2 to compare a hall sensor against the DAC output to check if a current is under the set limit.

Now I'd like to ignore very short bursts from inrush current, and glitches due to EMI, and also latch the error signal as raising the error status turns off the power, which should resolve the overcurrent situation.

My current idea is to feed the COMP2 output into a timer as a trigger signal (which allows me to use the timer's filter to wait for the signal to be stable for up to 16 cycles), and then count down from 1 to 0 in a one-shot timer, and use the underflow output as the outgoing error signal.

Reset isn't time critical, I can do that from the MCU.

  • Is that a feasible approach?
  • Can I expect the timers to behave sensibly with values this small?
  • Can I expect the underflow signal to remain asserted in one-shot mode?
  • Is there another method to implement a filter and a latch that isn't timer abuse?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.