0

I'm trying to use GPIO on my Beaglebone Black, but I'm running into some behavior I don't understand. I have two pins (gpios 27 and 61) configured to input with active_low set to 0. There is nothing connected to either pin (or any pin on the board for that matter), but one of the pins (gpio 61) is showing a value of 1 while gpio 27 shows a value of 0.

Can anyone explain why this is happening?

Here are the exact steps I took to get this result:

echo 27 > /sys/class/gpio/export
echo 61 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio27/direction
echo in > /sys/class/gpio/gpio61/direction
cat /sys/class/gpio/gpio27/value
0
cat /sys/class/gpio/gpio27/active_low
0
cat /sys/class/gpio/gpio61/value
1
cat /sys/class/gpio/gpio61/active_low
0
SimpleJ
  • 103
  • 3
  • 5
    Without anything connected to a general purpose input the value is undefined or in other words floating and can take on the value of high or low. To combat this, normally pull-up or pull-down resistors are used either externally or internally. – DigitalNinja Apr 15 '16 at 22:57
  • DigitalNinja is correct. You should not rely on a CMOS input to have one value or the other when nothing is connected to it. – The Photon Apr 15 '16 at 23:01
  • 1
    Read [Implications of Slow or Floating CMOS Inputs](http://www.ti.com/lit/pdf/scba004). – CL. Apr 16 '16 at 08:53

1 Answers1

2

It's possible that one or both GPIOs are not floating. Those states that you see could be caused by the internal pullup/pulldown resisters.

Are you familiar with Debian's device tree overlays? That is what you would use to configure the I/O pins on the BBB. Besides input and output, you can configure pins for drive-strength and enable/disable pullup and pulldown resistors.

Have a look here for details: http://derekmolloy.ie/gpios-on-the-beaglebone-black-using-device-tree-overlays/

Mark
  • 2,418
  • 11
  • 14