LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 10-03-2012, 05:56 AM   #1
bard
LQ Newbie
 
Registered: Oct 2012
Distribution: Debian
Posts: 10

Rep: Reputation: Disabled
GPIO issue on NanosG20 board


Hi all,

I have a nanosG20 with a bunch of GPIO pins.
After 'exporting' en setting the 'direction' and 'value' of the GPIO pins the voltage on the pins will not change when I change the 'value'

example:

pin 2 = PB17

echo 81 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio81/direction
echo 0(or 1) > /sys/class/gpio/gpio81/value

The voltage remains 3.3V. Adding a pull-down resistor of 10k does not help.

Also, according to the manual pin 12 should be 5V, I only measure 3.3V on that pin.

What am I doing wrong??

Last edited by bard; 10-05-2012 at 10:10 AM.
 
Old 10-05-2012, 10:06 AM   #2
bard
LQ Newbie
 
Registered: Oct 2012
Distribution: Debian
Posts: 10

Original Poster
Rep: Reputation: Disabled
I do not want to be a dick, but why do this post has over 100 views and not one reply?
I'm not an experienced programmer nor a electronics wizzard and I just need a tip or some advice...
Any help would be appreciated.

Kind regards

Last edited by bard; 10-05-2012 at 10:09 AM.
 
Old 10-05-2012, 01:37 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
It's because your question is very target specific. Only someone with first-hand experience with your board is likely to be able to give a qualified response. Also, your sample code includes no comments and is probably meaningless to most people. What does
Code:
pin 2 = PB17
mean? It isn't even valid shell syntax in any shell that I know. What is the significance of the '81' that seems to be sprinkled into your code? Is it supposed to be interpreted as hex?
I'm not trying to be a dick, either. Just trying to point out how you can help yourself.
--- rod.
 
Old 10-05-2012, 02:29 PM   #4
bard
LQ Newbie
 
Registered: Oct 2012
Distribution: Debian
Posts: 10

Original Poster
Rep: Reputation: Disabled
thx for your reply theNbomr!

Quote:
It's because your question is very target specific.
You are absolutely right! I should have known better.

On AT91SAM9G20 three gpiochips are available in /sys/class/gpio. These chips correspond to PIOA (/sys/class/gpio/gpiochip32), PIOB (/sys/class/gpio/gpiochip64) and PIOC (/sys/class/gpio/gpiochip96) each covering 32 GPIOs.

On this board I have a connector containing 26 GPIO pins.
example:
pin 2 on this connector represents address(?) (B)17 of gpiochip64, which makes 81 (17+64).
To transfer the gpio-pin to userspace and connect it to my hardware I have to 'export' it and set its 'direction' and 'value'.
Code:
echo 81 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio81/direction
echo 0(or 1) > /sys/class/gpio/gpio81/value
When I measure the voltage on that pin it remains 3.3V when I set the 'value' to low.
I have tried all types of pull-ups/down, but I can't get the output to change it 'physical'
value.
So I'm stuck...bigtime!
 
Old 10-05-2012, 05:48 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Okay, so I found Use GPIO pins from userspace, where it does describe what you're doing, and everything looks right according to that description. It would have been helpful for you to post a link to that page, but I see that your low post-count would probably prohibit that.
Have you tried another IO bit? Are you sure you are actually measuring the correct pin? Pins on a pin-header are usually numbered from pin 1 at one corner with the odd numbered pins on one row, and the even numbered pins on the other row. Many people start counting from pin 1, and assume the rest of the pins on the same row are numbered in sequence 2, 3, 4,...
It doesn't say so, but you may need root privileges to do what you're trying. Do you have that? I didn't dig into the type of output on the pins, but a common style is an open-drain, which requires a pullup for the bit to go high, and the chip pulls it low when a 0 is written.
The doc's say you supply 5VDC to the board but an on-board regulator drops this to the 3.3V required by the logic family of the chip(s) on the board.
When I'm trying to track down a pin's behavior, I sometimes like to create a loop that toggles the bit periodically:

Code:
echo 81 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio81/direction
state=0
while [ 1 ]; do
    echo $state > /sys/class/gpio/gpio81/value
    if [ $state -eq 0 ]; then
        state=1
    else
        state=0
    fi
    #  Maybe put a 'sleep 1' here...
done
Then, I can poke around ad nauseum with the scope or DVM probe, having both hands free while looking for a signal that has some identifiable characteristic.

--- rod.

Last edited by theNbomr; 10-05-2012 at 05:55 PM.
 
Old 10-06-2012, 08:06 AM   #6
bard
LQ Newbie
 
Registered: Oct 2012
Distribution: Debian
Posts: 10

Original Poster
Rep: Reputation: Disabled
thx very much for your time and advice!

I will test it again with the pull-up, I already did it but I will test it again in combination with your sample code.
I will post the result later!
 
Old 10-11-2012, 11:06 AM   #7
bard
LQ Newbie
 
Registered: Oct 2012
Distribution: Debian
Posts: 10

Original Poster
Rep: Reputation: Disabled
Just looked at it again, and some pins work and others do not. I just need to figure out why.
Thx again for your help.

Kind regards.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GPIO access on a Fujitsu Mini-ITX Industrial Mainboard, PCI Driver for GPIO mechatrix Linux - Embedded & Single-board computer 3 11-20-2011 03:57 PM
GPIO for PPC440 board junmuz Linux - Hardware 0 05-30-2011 09:08 AM
Using GPIO (from kernel GPIO support) in MY application DannyGilbert Linux - Kernel 2 03-16-2009 07:52 AM
gpio board FrollyC Linux - General 4 02-09-2008 08:38 AM
GPIO on Wrap.2c board jakev383 Linux - Hardware 0 02-12-2007 07:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 08:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration