Glomation
 
Advanced Search
Welcome, Guest. Please login or register.

Login with username, password and session length
May 22, 2012, 04:48:53 AM
News: Welcome to GLomation peer support forum
Pages: [1]
Topic Tools  
Read March 16, 2009, 02:36:08 AM #0
Rahim Pardhan

ADC + GPIO

Hello,

How can I access the GPIO and ADC pins on the 9260? I'm trying to interface a 3-axis accelerometer with the ADC and a bunch of limit switches to the GPIO. Any help is appreciated.

Regards,

Rahim
 
Read March 16, 2009, 12:53:43 PM #1
admin

Re: ADC + GPIO

The GPIO and ADC control registers are memory mapped and can be accessed directly from user space program.  The detailed information can be found in AT91SAM9260 user's manual.  There is an experimental GPIO driver posted in the forum.
 
Read March 16, 2009, 01:43:51 PM #2
Rahim Pardhan

Re: ADC + GPIO

The experimental driver is not for the 9260? Can I still use this?

Thanks,

Rahim
 
Read March 16, 2009, 01:55:02 PM #3
admin

Re: ADC + GPIO

It only require minor modification (change GPIO line to the pins available on GESBC-9260) and recompile.
 
Read March 16, 2009, 10:41:26 PM #4
Jerry Wong

Re: ADC + GPIO

We've been at this for hours and we still have nothing:

- After spending a lot of time figuring out the pinout, does J16 look like this (from top down):

1 2
3 4
5 6
...
47 48
49 50

This is the only numbering scheme in which things make sense for us, please confirm.

- We have implemented the experimental driver provided by Glomation for accessing GPIO. In both the driver as-provided and our own modified version, changing the value of a pin reports back successfully, but nothing happens on the J16 connector (the values do not change).

Can Glomation look in to this? This is a rather urgent problem for us, and it's disappointing that something as simple as GPIO doesn't work out of the box.

Here is a test output from our test app, for what it's worth:
Code:
GESBC:/GPIO# ./gpio-test.o                                                     
AT91_PIN_PB29 (TRIGGER) = 1                                                     
AT91_PIN_PB30 (RELOAD) = 1                                                     
AT91_PIN_PB31 (ZOOM) = 1                                                       
AT91_PIN_PC0 (SEG0_3) = 1                                                       
AT91_PIN_PC1 (SEG0_2) = 1                                                       
AT91_PIN_PC2 (SEG0_1) = 1                                                       
AT91_PIN_PC3 (SEG0_0) = 1                                                       
AT91_PIN_PC4 (SEG1_3) = 0                                                       
AT91_PIN_PC5 (SEG1_2) = 0                                                       
AT91_PIN_PC6 (SEG1_1) = 0                                                       
AT91_PIN_PC7 (SEG1_0) = 0                                                       
                                                                               
                                                                               
+PC4                                                                           
GESBC:/GPIO# ./gpio-test.o                                                     
AT91_PIN_PB29 (TRIGGER) = 1                                                     
AT91_PIN_PB30 (RELOAD) = 1                                                     
AT91_PIN_PB31 (ZOOM) = 1                                                       
AT91_PIN_PC0 (SEG0_3) = 1                                                       
AT91_PIN_PC1 (SEG0_2) = 1                                                       
AT91_PIN_PC2 (SEG0_1) = 1                                                       
AT91_PIN_PC3 (SEG0_0) = 1                                                       
AT91_PIN_PC4 (SEG1_3) = 0                                                       
AT91_PIN_PC5 (SEG1_2) = 0                                                       
AT91_PIN_PC6 (SEG1_1) = 0                                                       
AT91_PIN_PC7 (SEG1_0) = 0                                                       
                                                                               
                             

Between polls we tried changing PC4 to 1, which clearly does not work. Checking pins PC0 through PC7 is also confusing, as they definitely do not actually have voltages reflecting the 1,1,1,1,0,0,0,0 pattern as reported by the driver. All that aside, setting +PC0, +PC1, +PC2... etc do not seem to have any effect on the corresponding pins (all pins are zero in reality).

We have attached our driver code.

[edit] We have also alternatively tried using mmap to get GPIO working. We've attached the source for this as well. The mmap operation fails with (-EINVAL), but I simply cannot figure out what's wrong.
« Last Edit: March 17, 2009, 02:28:00 AM by Jerry Wong »
* GPIO-driver.c (9.89 KB - downloaded 108 times.)
* pio.c (3.63 KB - downloaded 102 times.)
 
Read March 17, 2009, 08:43:05 AM #5
admin

Re: ADC + GPIO

The pins on GPIO connector J16 is numbered as you indicated.

The GPIO will be supported by the next release of main line Linux kernel.

For quick testing you can use the following sequence of commands to check GPIO PC10,

devmem2 0xfffff800 w 0x400
devmem2 0xfffff810 w 0x400
devmem2 0xfffff830 w 0x400
sleep 5
devmem2 0xfffff834 w 0x400

devmem2 is a utility program that allows access of any memory location from user space.  The source code can be downloaded from http://free-electrons.com/pub/mirror/devmem2.c

Your pio-1.c program doesn't seem to reset the output value at correct register.  Please see above example.  Anothing you can try in your poi-1.c program is to toggle one output line with some sleep interval so you can connect a LED or meter to check the output voltage level change.

 
Read March 17, 2009, 03:20:40 PM #6
Jerry Wong

Re: ADC + GPIO

Our PIO app doesn't even get that far Smiley It fails on mmap. Do you have any pointers on what we're doing wrong? It doesn't seem to want to map that address for us.
 
Read March 17, 2009, 04:08:46 PM #7
admin

Re: ADC + GPIO

Please use devmem2 memory mapping as reference.

Try to change the memory mapping call to,

mem_page = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, PIO_C & ~MAP_MASK);

 
Pages: [1]
Jump to:  

Theme Update by Runic Warrior Originally created by m3talc0re