Beaglebone gpio input not working

duslabo picture duslabo · Aug 19, 2012 · Viewed 11.7k times · Source

I am using beaglebone to access digital input from specific pin using sysfs interface. And I can change the output states but not the input :(. What I did is, I have two pins pinA and pinB. pinA I made it output and pinB I made input. Connected pinA to pinB. Configured pinA as output pin by sending out to direction attribute in sysfs and pinB as input by passing in. And I changed value of PinA to 1 and it is giving 1 as output (I tested using LED). But when I read the value of PinB it is giving 0 only, even I pass 0 to value of pinA. what may be the reason ?

Thank you :)

Answer

Ibrahim Arli picture Ibrahim Arli · Oct 3, 2012

As I understood, the steps you followed:

echo 7 > /sys/kernel/debug/omap_mux/gpmc_ad6
echo 38 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio38/direction
cat /sys/class/gpio/gpio38/value

I also did the same mistake and it took me hours, but the answer was simple: The first line starting with "echo 7" is the problem. Look at the muxing bits:

Bit 5: 1 - Input, 0 - Output

Bit 4: 1 - Pull up, 0 - Pull down

Bit 3: 1 - Pull disabled, 0 - Pull enabled

Bit 2 \

Bit 1 |- Mode

Bit 0 /

You were entering echo 7 which is --> 0 0 0111 and it means: bit 0,1 and 2 is 1, so the mode is set. No problem. However you just forgot to set whether it's an input or output. And it should be like this:

echo 0x27 > /sys/kernel/debug/omap_mux/gpmc_ad6

your bits are now: 1 0 0111 binary which is 0x27 (hex).

When you write "cat /sys/class/gpio/gpio38/value" while giving input, you can see a wonderful 1 :) I’m sure you will be very happy as much as I was :)

Also, one more thing, you are right for Analog input about 1.8V, but GPIO operates with 3.3v.