Sample Header Ad - 728x90

A/D pins always read max (1023)

1 vote
0 answers
159 views
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 = ; atmel,adc-num-channels = ; compatible = "atmel,at91sam9x5-adc"; atmel,adc-startup-time = ; atmel,adc-status-register = ; atmel,adc-trigger-register = ; atmel,adc-use-external; atmel,adc-vref = ; atmel,adc-res = ; atmel,adc-res-names = "lowres", "highres"; atmel,adc-use-res = "highres"; trigger@0 { trigger-name = "continuous"; trigger-value = ; }; };
Asked by DeusAduro (123 rep)
Oct 2, 2015, 06:40 AM
Last activity: Dec 31, 2022, 07:56 PM