Interrupt (RISING) - triggers twice

I have been looking at incoming signal in more details and it seems that in the first 30 usecs of the signal (LOW -> HIGH) it bounces a couple of time. That could very well be the cause ...... :frowning:

Will use another oscilloscoop tomorrow. After that I will share my findings here.


I would attach ONCE, in setup(), then leave it alone.
Use enable/disable within your code.

I haven’t tested to see what happens if you attach when the input is already high/low - but i’d be looking around there.
Unless you’re using multiple interrupt sources, there’s no real need to muck around with EIFR that I can see.

After some thoughts, discussions and blaming the 328p and the software I had to come to the conclusion that the signal from the opamps going to the microprocessor bounced due to some output swing. This bouncing happens in a couple of micro seconds.

Therefore my solution had to come from the hardware design. Due to noise on the signal the comparator swings a couple of times between high and low (see screenshot). Solution was to improve the hysteresis of the comparator to increase thresholds.

This improved hardware works like a charm and interrupts work good (no interrupts are generated twice) (see attached screenshots).

  • Output swing / bouncing is difficult to find without a proper oscilloscoop (only a few micro secs)
  • Good info on the comperator hysteresis: TI app note on hysteresis

Thanks for thinking along!