Using GPIO to toggle and LED

14 views
Skip to first unread message

AvantSavant

unread,
Nov 25, 2012, 11:49:48 PM11/25/12
to pico-S...@googlegroups.com
I'm trying to drive an LED with the pico-SAM9G45 board, and it appears that using GPIO is the way to go to drive a small LED/transistor circuit.  I've never used GPIO, and I haven't found much documentation for it on the sam9.  I've read up on it on other web sites for other devices, but is there anywhere I can get a more detailed description of how to use it?  The pages on the wiki do not go into much detail either. 

I'm running console-only Ansgrom, and I'd rather not recompile the kernel as described in http://arm.mini-box.com/index.php?title=Kernel_changes_for_custom_hardware.

I followed the instructions in the "Working with GPIOs" section to set the output to 1, but I did not see where any voltage went high on the J14 connector.  So I'm guessing that my understanding of how it works is wrong.

Also, could someone point me to a description of how the GPIO convention works?  I would not have known that J14 pin 5 was PC19, for example.  


Nicu Pavel

unread,
Nov 26, 2012, 11:17:13 AM11/26/12
to pico-S...@googlegroups.com
On Mon, Nov 26, 2012 at 6:49 AM, AvantSavant <dgwa...@gmail.com> wrote:
I'm trying to drive an LED with the pico-SAM9G45 board, and it appears that using GPIO is the way to go to drive a small LED/transistor circuit.  I've never used GPIO, and I haven't found much documentation for it on the sam9.  I've read up on it on other web sites for other devices, but is there anywhere I can get a more detailed description of how to use it?  The pages on the wiki do not go into much detail either. 

I'm running console-only Ansgrom, and I'd rather not recompile the kernel as described in http://arm.mini-box.com/index.php?title=Kernel_changes_for_custom_hardware.

I followed the instructions in the "Working with GPIOs" section to set the output to 1, but I did not see where any voltage went high on the J14 connector.  So I'm guessing that my understanding of how it works is wrong.

If you configured the GPIO correctly as output you can also read it's value back with cat   /sys/class/gpio/gpio115/value and should be 1. Voltage should increase from 0 to 3.3V when you write 1.
If you can't make it work just try another GPIO.

 

Also, could someone point me to a description of how the GPIO convention works?  I would not have known that J14 pin 5 was PC19, for example.  

There isn't really a convention. You will have to look at the board schematics and on page 8/9 you see that USR1 pin is routed to PC19 input on microcontroller. 

Regards,
Nicu Pavel

AvantSavant

unread,
Nov 28, 2012, 1:00:39 AM11/28/12
to pico-S...@googlegroups.com
The voltage did not rise at all from 0 when I set the value to 1.  

Nicu Pavel

unread,
Nov 28, 2012, 3:06:29 PM11/28/12
to pico-S...@googlegroups.com
On Wed, Nov 28, 2012 at 8:00 AM, AvantSavant <dgwa...@gmail.com> wrote:
The voltage did not rise at all from 0 when I set the value to 1.  


Make sure you are following these steps (this is for PC19 that's why 115 is exported (96 which is C port in MCU + 19 the address)

 cd /sys/class/gpio/
 echo "115" > /sys/class/gpio/export
 cd /sys/class/gpio/gpio115/
 echo out > direction
 echo 1 > value 
cat value

The last command it's to verify that you actually written a valuee and should should show 1


Nicu

Srgian Danity

unread,
Sep 27, 2013, 6:15:45 AM9/27/13
to pico-S...@googlegroups.com
Hi, I want to use TXD1 and RXD1 as GPIO pins. Is this possible without bounding/unbounding in kernel those pins? I had success controlling PORTC pins allocated to USR[1..4] but not with PB4 and PB5 exporting gpio 68 and 69. How about using PB0 and PB1 since those are bound to SPI. Same procedure as USART?

Any help is very appreciated. 
Reply all
Reply to author
Forward
0 new messages