0
\$\begingroup\$

I've encountered a weird problem and I'm not sure whether it's actually a problem or everything's ok.

But going straight to the point. I've got Raspberry Pi Zero W, one of its pins is configured as GPIO IN, with interrupt triggered when falling edge is detected. GPIO has attached external, hardware pull-up 10K.

The interrupt is handled in my kernel driver, also I've been using one of the debouncing techniques that uses jiffies. And it seemingly looks ok, but there is actually one problem - I don't have to ground the pin in order to cause the interrupt.

I can take one of my multimeter's probes and touch the pin and then an interrupt occurs. Is it normal? Shouldn't it be a little bit less sensitive? Shouldn't the interrupt be triggered when pin's state changes to 0 (when I ground it)?

I also tried to use an RC filter but it didn't help.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Probably your pull-up isn't working. \$\endgroup\$
    – Eugene Sh.
    Commented Nov 9, 2021 at 19:46
  • \$\begingroup\$ could you elaborate on the RC part as well? Normally pulling up and using a cap directly at the input is used to increase the input robustness. If this does not work it is likely an issue of the exact execution/implementation not of the approach itself. \$\endgroup\$ Commented Nov 9, 2021 at 19:49
  • \$\begingroup\$ As for the RC, I used 1k resistor and 100uF capacitor. But, still, I had too many falling-edge interrupts detected (basically it didn't help at all). So I made the simplest circuit without any unnecessary elements, but it didn't help. I suspect that something may be wrong with pull-up - but to be honest, adding hardware pull-up is not complicated and I have no idea what could go wrong. It's just my guess but I think with a properly installed pull-up, even without RC filter, there shouldn't be any interrupts, triggered just by attaching a probe. \$\endgroup\$
    – bielu000
    Commented Nov 9, 2021 at 20:15
  • \$\begingroup\$ Using external interrupts for a switch is bad juju. Given a length of wire it can pick up RF from your mobile phone and cripple the Pi with a zillion interrupts which you have no control over. It works on the bench but fails in the field. \$\endgroup\$
    – Kartman
    Commented Nov 9, 2021 at 21:02
  • \$\begingroup\$ @Kartman So what would you use instead? \$\endgroup\$
    – bielu000
    Commented Nov 9, 2021 at 21:39

1 Answer 1

1
\$\begingroup\$

Raspberry Pis like most other electronic devices have a range for voltages it sees as low or high. And indeterminate states.

No publicly available datasheet from Broadcom for the Rpi cpu is out there but generally speaking, the range is Gnd to ~1.3V is low, 1.3V to 1.8V is a halfway weird space and 1.8V to VCC is high.

If you have the internal pull down enabled (rpi pins have both pull ups and pull down options, sometimes), along with your weak external pull up, you could have a voltage divider pulling the pin to the bottom of the High state, so anything that pulls it down slightly could trigger the transition.

Make sure the pull down isn't enabled, and if you still have issues try a stronger pull up like 4.7K.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ There is a datasheet available, somewhat by proxy, using the CM4 datasheet (datasheets.raspberrypi.com/cm4/cm4-datasheet.pdf) $$V_\mathrm{IL} = 0.8~\mathrm{V}$$ for a 3V3 GPIO pin. Table 4. \$\endgroup\$
    – awjlogan
    Commented Nov 9, 2021 at 20:55
  • 1
    \$\begingroup\$ Ah. In that case the CM1 datasheet is better for the BCM2835 that's on the zero w. Still shows a 0.8V but at 2.7 VDD_io so a bit more at 3.3V. Both sheets seem to contradict most people's experiences online about the thresholds though. \$\endgroup\$
    – Passerby
    Commented Nov 9, 2021 at 21:26
  • \$\begingroup\$ I'm sure I've been using the appropriate pull-up configuration. I tested a few scenarios, also including pull-down resistor, and in this case on a pin when I've got an external pull up resistor the voltage was ~2.8V so I guess that was because of the internal pd resitor, therefore there was voltage divider created. So I switched back to internal pu/none configuration (I think in case of external pull up both configratuons are fine). What's important, external pull up is stronger, as it gives me 3.25V on a pin whereas having internal pull up supplies only 3.10V. Anyways problem still occurs. \$\endgroup\$
    – bielu000
    Commented Nov 9, 2021 at 21:56
  • \$\begingroup\$ But correct me if I'm wrong - should I expect an interrupt not to be triggered while just touching the probe to my pin if pull up works fine? \$\endgroup\$
    – bielu000
    Commented Nov 9, 2021 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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