1

I am using the Aria G25 board from Acme Systems. I have their Terra board breakout. I have also asked this question on their google groups but thought it might be a more general issue so have posted here as well. I have built the ADC into the kernel (not as module) based on this guide:

http://www.at91.com/linux4sam/bin/view/Linux4SAM/IioAdcDriver

At startup I am able to grep for iio and get:

root@acmeboard:~# dmesg | grep iio                                              
iio iio:device0: Resolution used: 10 bits                                       
iio iio:device0: ADC Touch screen is disabled.

After startup I have the appropriate sysfs structure:

root@acmeboard:~# ls -l /sys/bus/iio/devices/iio\:device0/                      
total 0                                                                         
drwxr-xr-x 2 root root    0 Jan  1 01:06 buffer                                 
-r--r--r-- 1 root root 4096 Jan  1 01:06 dev                                    
-rw-r--r-- 1 root root 4096 Jan  1 01:01 in_voltage0_raw                        
-rw-r--r-- 1 root root 4096 Jan  1 01:01 in_voltage1_raw                        
-rw-r--r-- 1 root root 4096 Jan  1 01:01 in_voltage2_raw                        
-rw-r--r-- 1 root root 4096 Jan  1 01:01 in_voltage3_raw                        
-rw-r--r-- 1 root root 4096 Jan  1 01:06 in_voltage_scale                       
-r--r--r-- 1 root root 4096 Jan  1 01:06 name                                   
drwxr-xr-x 2 root root    0 Jan  1 01:06 power                                  
drwxr-xr-x 2 root root    0 Jan  1 01:06 scan_elements                          
lrwxrwxrwx 1 root root    0 Jan  1 01:06 subsystem -> ../../../../../bus/iio    
drwxr-xr-x 2 root root    0 Jan  1 01:06 trigger                                
-rw-r--r-- 1 root root 4096 Jan  1 01:06 uevent  

However when attempting to read the ADC value I always get 1023 (I have a potentiometer connected on one of their breakout boards, so I would expect to not read the max):

root@acmeboard:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw         
1023 

I am relatively new to linux and sysfs so I could be missing something simple. Other point of interest. If I read the same pin (W20 on Aria) as a digital GPIO it appears to work. Spinning the pot I eventually read 0 and then 1 going the other way. Do I some how need to disable the GPIO functionality for this pin?

Finally here is the relevant lines in the DTS file (only thing I've changed):

adc0: adc@f804c000 {
                status = "okay";
                atmel,adc-channels-used = <0xf>;
                atmel,adc-num-channels = <4>;
                compatible = "atmel,at91sam9x5-adc";
                atmel,adc-startup-time = <40>;
                atmel,adc-status-register = <0x1c>;
                atmel,adc-trigger-register = <0x08>;
                atmel,adc-use-external;
                atmel,adc-vref = <3250>;
                atmel,adc-res = <8 10>;
                atmel,adc-res-names = "lowres", "highres";
                atmel,adc-use-res = "highres";
                trigger@0 {
                        trigger-name = "continuous";
                        trigger-value = <0x6>;
                };
            };
Marcus Müller
  • 21,602
  • 2
  • 39
  • 54
DeusAduro
  • 123
  • 4
  • 1
    The only way to know why you read a particular value exported to sysfs is to read documentation and/or sources of that particular driver. Another thing I would try is to connect the A/D pin to ground and check if you read 0. Anyway, it's not really a UNIX question. I would move it to http://electronics.stackexchange.com/ – Dmitry Grigoryev Oct 02 '15 at 07:35
  • Does this have anything to do with multiplexing? – daltonfury42 Oct 02 '15 at 07:52
  • Is there a way to directly move the question or should I delete it and repost there? – DeusAduro Oct 02 '15 at 23:30

0 Answers0