I am trying to generate a pulse to trigger an interrupt when the input changes state.
High->Low & Low->High

The input is a reed switch.
I'm using a XOR gate (SN74AHC1G86QDBVRQ1) with an RC delay on one input.
GPIO2 is used for detecting the state of the input after the MCU wakes from the interrupt.
The circuit works correctly when changing from Low->High. When changing from high to low, it will only work when a scope probe or another metal object is touching terminal 2 (GPIO2).

Does anyone have any suggestions on why this is happening?

Edge Detection

  • 1
    \$\begingroup\$ A reed switch is just a switch. It doesn't both sink and source on its own. If you've tied one end to \$V_\text{CC}\$, then it can source when closed but it cannot sink when open. \$\endgroup\$
    – jonk
    Dec 12, 2018 at 7:34

1 Answer 1


The problem is that when the reed switch opens, the GPIO2 pin is pulled down through the 10 meg resistor. The parasitic caps around your circuit might produce an erratic and unpredictable behavior, because the node GPIO2 is basically high impedance.

To solve your problem, the easiest way I see is to reduce the 10 M as low as your reed switch allows, change RD to at least 10x RPD, or 100x if possible, and reduce C accordingly to keep your time constant.

You can also try to build up a push pull driver for your edge detection circuit, but things get a little more complicated.

I will close with another suggestion: I assume you have a microcontroller that reads these pulses and does something as a consequence. Most (all?) microcontrollers allow you to edge trigger an interrupt, so basically they already have inside all the necessary circuitry. Read your micro's manual carefully, I bet your solution is just changing a bit in a register somewhere.

  • \$\begingroup\$ I witness the same behavior whether RPD is populated or not. This is being applied in a power constraint application so I cant decrease RPD to much. I can't increase RD (much) due to the decrease in voltage of the input below the XOR gate threshold. Ultimately I would have preferred to just use the MCU Rising|Falling interrupt function as opposed to just a Rising Interrupt. The MCU is encased within another device which uses a propriety library and limits the functionality to configure. \$\endgroup\$
    – Lanc
    Dec 13, 2018 at 3:03
  • \$\begingroup\$ The value of RD does not set the voltage that the XOR gate sees. If this is a power constrained application, then add a CMOS buffer with input between the reed and RPD1, and output connected to both RD and pin 1 of the XOR. \$\endgroup\$ Dec 13, 2018 at 11:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.