Welcome, Guest

Author Topic: GPIO problems  (Read 5633 times)

Hellgringo

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
GPIO problems
« on: October 30, 2012, 05:38:12 PM »
Hi,

I connected a green LED and a 600ohm resistor between pin 18 and 2 of the 40pin GPIO connector.
The LED lights up at startup but if I change the gpio state (/sys/class/gpio51) to 0 the LED is still
on. I checked the pins several times... no idea.

I use arch linux 2.6.35-8-ARCH+ without modifications.

Fadil Berisha

  • Full Member
  • ***
  • Posts: 124
  • Karma: +7/-0
Re: GPIO problems
« Reply #1 on: October 30, 2012, 07:08:17 PM »

The LED lights up at startup but if I change the gpio state (/sys/class/gpio51) to 0 the LED is still
on.
To help you beter, we need to know your sequence to change state. If pin is defined in kernel as GPIO ,try this sequence:

Export and set direction:

echo 51 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio51/direction

Change value on pin 51:

 echo 0 > /sys/class/gpio/gpio51/value
 echo 1 > /sys/class/gpio/gpio51/value
 echo 0 > /sys/class/gpio/gpio51/value

Regards
Fadil Berisha
« Last Edit: October 30, 2012, 07:19:32 PM by Fadil Berisha »

Hellgringo

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: GPIO problems
« Reply #2 on: October 30, 2012, 08:20:39 PM »
I tried it this way which worked for the onboard led

echo out > /sys/class/gpio/gpio65/direction
echo 0 > /sys/class/gpio/gpio65/value
echo 1 > /sys/class/gpio/gpio65/value
echo 0 > /sys/class/gpio/gpio65/value

the same thing for gpio51 didn't work.

The following command results in an error
echo 51 > /sys/class/gpio/export
-bash: echo: write error: Device or resource busy

Regards
Holger

Hellgringo

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: GPIO problems
« Reply #3 on: October 31, 2012, 01:23:00 PM »
Sorry, my fault.

There was a short circuit...

I have another question, what would be the fastest way to read the gpios values with in a C program?
I thought of opening the gpios as files, read the content and close. But I think this won't be very
fast cause of the usage of open() close() sys calls.

Thx


olimex

  • Administrator
  • Hero Member
  • *****
  • Posts: 806
  • Karma: +22/-3
Re: GPIO problems
« Reply #4 on: October 31, 2012, 01:26:03 PM »