-   Linux - Embedded & Single-board computer (
-   -   GPIO issue on NanosG20 board (

bard 10-03-2012 05:56 AM

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'


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??

bard 10-05-2012 10:06 AM

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

theNbomr 10-05-2012 01:37 PM

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

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.

bard 10-05-2012 02:29 PM

thx for your reply theNbomr!


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.
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'.

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'
So I'm stuck...bigtime!

theNbomr 10-05-2012 05:48 PM

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:


echo 81 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio81/direction
while [ 1 ]; do
    echo $state > /sys/class/gpio/gpio81/value
    if [ $state -eq 0 ]; then
    #  Maybe put a 'sleep 1' here...

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.

bard 10-06-2012 08:06 AM

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!

bard 10-11-2012 11:06 AM

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.

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