This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Unable to run the example of generic-buffer.c for ADC on BBB

Hi All,

I have modified the file arch/arm/boot/dts/am335x-bone-common.dtsi to enable the ADC and got the ADC to work in terms of reading the analog value using:

cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw

Output:

368 (V ain = 0.161V) which is my input reading.


But I am unable to run the generic-buffer.c example on Beaglebone Black

Command:

root@am335x-evm:~# ./generic_buffer -n TI-am335x-adc -l 256 -c 3

Output:

iio device number being used is 0
Problem reading scan element information
diag /sys/bus/iio/devices/iio:device0

The dir structure of my sysfs for ADC is as follows:

ls -al /sys/bus/iio/devices/iio\:device0/

o/p:

drwxr-xr-x    3 root     root             0 Jan  1  2000 .
drwxr-xr-x    4 root     root             0 Jan  1  2000 ..
-r--r--r--    1 root     root          4096 Apr  1 12:03 dev
-rw-r--r--    1 root     root          4096 Apr  1 12:24 in_voltage0_raw
-rw-r--r--    1 root     root          4096 Apr  1 12:03 in_voltage1_raw
-rw-r--r--    1 root     root          4096 Apr  1 12:03 in_voltage2_raw
-rw-r--r--    1 root     root          4096 Apr  1 12:03 in_voltage3_raw
-rw-r--r--    1 root     root          4096 Apr  1 12:03 in_voltage4_raw
-rw-r--r--    1 root     root          4096 Apr  1 12:03 in_voltage5_raw
-rw-r--r--    1 root     root          4096 Apr  1 12:03 in_voltage6_raw
-rw-r--r--    1 root     root          4096 Apr  1 12:03 in_voltage7_raw
-r--r--r--    1 root     root          4096 Apr  1 11:59 name
drwxr-xr-x    2 root     root             0 Apr  1 12:03 power
lrwxrwxrwx    1 root     root             0 Jan  1  2000 subsystem -> ../../../../../bus/iio
-rw-r--r--    1 root     root          4096 Jan  1  2000 uevent

Note: I am using the latest TI SDK version 7

Has anyone able to make it work ?

  • Hi,

    The error message comes from the generic_buffer.c file:

        /*
         * Parse the files in scan_elements to identify what channels are
         * present
         */
        ret = build_channel_array(dev_dir_name, &channels, &num_channels);
        if (ret) {
            printf("Problem reading scan element information\n");
            printf("diag %s\n", dev_dir_name);
            goto error_free_triggername;
        }

    Try to debug why and post some more information here. The build_channel_array() function is in the iio_util.h in the same folder.

    Best regards,
    Miroslav

  • Hi Miroslav,

    Thanks for your response.

    I did debug it and found that the sysfs directory structure of iio for which the code has been written is

    quite different from the sysfs dir structure in new SDK (TI SDK v 07).

    I ended up writing my own example for reading the inputs directly from the:

    /sys/bus/iio/devices/iio\:device0/in_voltage0_raw and other files.

    Also another observation I found is that there are no way to check what mode (One-shot or Continuous) the ADC is operating in, in the new dir structure.

    There is change in mode possible as well.

    Please let me know in case of any deviation.

  • Hi Harsha,

    Continuous capture mode is not supported in the 3.12 kernel (SDK v7). Check the known ADC issues for SDK v7 here: http://processors.wiki.ti.com/index.php/Sitara_Linux_SDK_ADC

    Best regards,
    Miroslav