ad7991 with odc - Unable to create buffer

Hi,

I am using the ad7991 adc with the Raspberry Pi2.

Reading single values from the \iio:device0\in_voltage0_raw works fine, but when trying to stream the data with osc, I am getting errors "Error while reading data: Resource temporarily unavailable". My host pc is lubuntu 14.04.

from the output of iio_info I see it cannot read some of the the attributes (add_trigger, raw, etc), even running with sudo.

I have connected the iio-trig-sysfs by "echo sysfstrig1 > current_trigger". Maybe this is not the right trigger to use... but thought using it for testing purposes only.

loading the hrtimer trigger by "sudo modprobe iio-trig-hrtimer" didnt actually created the trigger as i hoped it do.. for this i tried adding the following code in my bcm2709.c board file (found on this forum):

static const char *hrtimer_trigger_pdata[] = {  
     "0", /* 0 is the name of the trigger */  
     NULL,  
};  
  
static struct platform_device hrtimer_trigger = {  
     .name = "iio_hrtimer_trigger",  
     .dev = {  
          .platform_data = &hrtimer_trigger_pdata,  
     },  
}; 

and registering the device with:

platform_device_register(&hrtimer_trigger);

still didnt show up the hrtimer0 iio device..

can somebody point me in the right direction what causes this problem and why the hrtimer trigger dont show up?

  • output of iio_info from the raspberry pi:

    pi@raspberrypi:~ $ iio_info
    Library version: 0.6 (git tag: 07e40a0)
    IIO context created with local backend.
    Backend version: 0.6 (git tag: 07e40a0)
    Backend description string: Linux raspberrypi 4.6.0-rc7-v7+ #1 SMP Tue May 17 17:09:01 CEST 2016 armv7l
    IIO context has 3 devices:
        trigger0: sysfstrig1
            0 channels found:
            1 device-specific attributes found:
    Unable to read attribute trigger_now: Permission denied
        iio_sysfs_trigger: 
            0 channels found:
            2 device-specific attributes found:
    Unable to read attribute add_trigger: Permission denied
    Unable to read attribute remove_trigger: Permission denied
        iio:device0: ad7991
            5 channels found:
                voltage0:  (input)
                5 channel-specific attributes found:
    Unable to read attribute raw: Device or resource busy
                    attr 1: index value: 0
                    attr 2: en value: 1
                    attr 3: type value: be:u12/16>>0
    Unable to read attribute scale: Invalid argument
                voltage1:  (input)
                5 channel-specific attributes found:
    Unable to read attribute raw: Device or resource busy
                    attr 1: en value: 0
                    attr 2: index value: 1
                    attr 3: type value: be:u12/16>>0
    Unable to read attribute scale: Invalid argument
                voltage2:  (input)
                5 channel-specific attributes found:
    Unable to read attribute raw: Device or resource busy
                    attr 1: en value: 0
                    attr 2: index value: 2
                    attr 3: type value: be:u12/16>>0
    Unable to read attribute scale: Invalid argument
                voltage3:  (input)
                5 channel-specific attributes found:
    Unable to read attribute raw: Device or resource busy
                    attr 1: en value: 0
                    attr 2: type value: be:u12/16>>0
                    attr 3: index value: 3
    Unable to read attribute scale: Invalid argument
                timestamp:  (input)
                3 channel-specific attributes found:
                    attr 0: type value: le:s64/64>>0
                    attr 1: index value: 4
                    attr 2: en value: 0
    
  • 0
    •  Analog Employees 
    on May 26, 2016 12:34 AM

    Hi,

         Please share scope plots of the communication (SCL and SDA) of the AD7991 so we can have a better understanding of the problem. You may also want to check the AD7991 wiki page, there is an available software driver for the AD7991 to refer the code that you are developing.  Kindly refer to this link AD799x - No-OS Driver for Microchip Microcontroller Platforms [Analog Devices Wiki]

    Regards,

    Jonathan

  • Hi,

    The hrtimer is not part of upstream Linux. If it is not part of your RPI kernel tree you'll have to import it, e.g. from the ADI tree.

    But my recommendation would be to pick up the new configfs based hrtimer from the upstream tree. This trigger can be created from userspace using configfs and does not require any kernel changes to register or create such a trigger. Be aware though that this driver has a few dependencies that also need to be imported.

    - Lars

  • Hi,

    thank you for your reply.

    I've connected the scope on the SCL and SDA pins, but there is absolutely no activity on both pins.when using the osc application to read a single value (read input voltage on the 'debug' tab), it works fine and i can see activity on the pins.

    I think the osc application cannot plot the waveform because there is no periodic trigger attached to it. The only trigger I've successfully attached is the sysfstrig which needs manual triggering.

    My question is how to plot the waveform with the osc using the ad7991 with the sysfstrig?

    and if it isnt possible to use the sysfstrig for plotting, how can I get the hrtimer trigger to appear as IIO device in /sys/bus/iio/devices?

    Thanks in advance

    Kind regards,

    Ramoe

  • Hi,

    Sorry for the delayed response.

    I've succesfully created the hrtimer from userspace through the configfs, thanks! it began to work when updating the rpi kernel to version 4.6.y.

    The problem I'm facing right now is when enabling the buffer (after enabling the in_voltage0_en), the kernel crashes.

    Does the ad7991 needs to be configured somehow as a trigger consumer in the device-tree?

    Thanks in advance,

    Ramoe