Post Go back to editing

DAC AD5362 Issue

Hi,

 I am using AD5362 in my design which is interfaced with sitara processor.I modified kernel and added device tree node. Device is getting enumerated in /sys/bus/iio/devices.

The Vout of the DAC is fixed at 0.114V and not changing at all and I am not able to write any value to it (read error: Invalid argument is the error i am getting) following are the logs-

root@am57xx-evm:/sys/bus/iio/devices/iio:device2# ls
dev                      out_voltage2_raw         out_voltage5_scale
name                     out_voltage2_scale       out_voltage6_calibbias
of_node                  out_voltage3_calibbias   out_voltage6_calibscale
out_voltage0_calibbias   out_voltage3_calibscale  out_voltage6_offset
out_voltage0_calibscale  out_voltage3_offset      out_voltage6_raw
out_voltage0_offset      out_voltage3_raw         out_voltage6_scale
out_voltage0_raw         out_voltage3_scale       out_voltage7_calibbias
out_voltage0_scale       out_voltage4_calibbias   out_voltage7_calibscale
out_voltage1_calibbias   out_voltage4_calibscale  out_voltage7_offset
out_voltage1_calibscale  out_voltage4_offset      out_voltage7_raw
out_voltage1_offset      out_voltage4_raw         out_voltage7_scale
out_voltage1_raw         out_voltage4_scale       out_voltage_powerdown
out_voltage1_scale       out_voltage5_calibbias   power
out_voltage2_calibbias   out_voltage5_calibscale  subsystem
out_voltage2_calibscale  out_voltage5_offset      uevent
out_voltage2_offset      out_voltage5_raw
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat name
ad5362
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage0_raw
1024
ale @am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage0_calibsca
25600
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage0_raw
1024
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage1_raw
1152
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage2_raw
1280
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage3_raw
1408
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage4_raw
1536
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage5_raw
1664
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage6_raw
1792
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage7_raw
1920
root@am57xx-evm:/sys/bus/iio/devices/iio:device2#
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage0_scale
cat: read error: Invalid argument
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage1_scale
cat: read error: Invalid argument
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage2_scale
cat: read error: Invalid argument
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage3_scale
cat: read error: Invalid argument
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage4_scale
cat: read error: Invalid argument
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# echo 1000 > out_voltage0_raw
root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage0_raw
1024

Parents
  • In the driver, it looks like you need to provide 2 reference regulators:

            [ID_AD5362] = {
                    .channel_template = AD5360_CHANNEL(16),
                    .num_channels = 8,
                    .channels_per_group = 4,
                    .num_vrefs = 2,
            },

    num_vrefs is 2

    the error " Invalid argument" seems to be coming from a missing regulator most likely;

    you need to add these regulators in the device-tree;

    even if you just specify some fixed-regulator property that has a fixed value;

Reply
  • In the driver, it looks like you need to provide 2 reference regulators:

            [ID_AD5362] = {
                    .channel_template = AD5360_CHANNEL(16),
                    .num_channels = 8,
                    .channels_per_group = 4,
                    .num_vrefs = 2,
            },

    num_vrefs is 2

    the error " Invalid argument" seems to be coming from a missing regulator most likely;

    you need to add these regulators in the device-tree;

    even if you just specify some fixed-regulator property that has a fixed value;

Children
  • Hi aardelean,

    We added vref in dts and now invalid argument is not coming and i am able to read scale property.

    But, whenever i am trying update out_voltage0_raw or any other channels that value is not getting updated and hence i am not getting analog out of that channel.what changes i have to do in driver?

  • root@am57xx-evm:/sys/bus/iio/devices/iio:device2# echo 1000 > out_voltage0_raw
    root@am57xx-evm:/sys/bus/iio/devices/iio:device2# cat out_voltage0_raw
    1024

    if you try other values, do you still read 1024?

    how is the board connected?

    maybe reduce the SPI frequency to a few kilohertz to see if this helps; SPI sensive above 1 Mhz, and you need good connections to go to a few Mhz;

    did you configure the proper SPI modes? it looks like this would need SPI mode 1 [if i am reading the datasheet correctly], so in the device-tree you'd need to set the "spi-cpha" property so that it's in mode 1.

    i don't have an eval board with this chip around to test

  • Hi aardelean,

    device tree node is as follows-

    &mcspi3{
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&mcspi3_pins_default>;
        ti,pindir-d0-out-d1-in;
        ti,spi-num-cs = <1>;
        dmas = <&sdma_xbar 15>,
               <&sdma_xbar 16>;
        dma-names="tx0","rx0";

        ad5362@0{
            compatible = "adi,ad5362";
            reg = <0>;
            spi-max-frequency = <10000000>;
            spi-cpha;
            vref0-supply = <&vref0>;
            vref1-supply = <&vref1>;
        };

    };

    contents of the registers of the DAC -

    root@am57xx-evm:/sys/bus/iio/devices/iio:device2# grep "" *
    dev:249:2
    name:ad5362
    out_voltage0_calibbias:17408
    out_voltage0_calibscale:25600
    out_voltage0_offset:-132096
    out_voltage0_raw:1024
    out_voltage0_scale:0.183105468
    out_voltage1_calibbias:17536
    out_voltage1_calibscale:25728
    out_voltage1_offset:-132096
    out_voltage1_raw:1152
    out_voltage1_scale:0.183105468
    out_voltage2_calibbias:17664
    out_voltage2_calibscale:25856
    out_voltage2_offset:-132096
    out_voltage2_raw:1280
    out_voltage2_scale:0.183105468
    out_voltage3_calibbias:17792
    out_voltage3_calibscale:25984
    out_voltage3_offset:-132096
    out_voltage3_raw:1408
    out_voltage3_scale:0.183105468
    out_voltage4_calibbias:17920
    out_voltage4_calibscale:26112
    out_voltage4_offset:-132608
    out_voltage4_raw:1536
    out_voltage4_scale:0.183105468
    out_voltage5_calibbias:18048
    out_voltage5_calibscale:26240
    out_voltage5_offset:-132608
    out_voltage5_raw:1664
    out_voltage5_scale:0.183105468
    out_voltage6_calibbias:18176
    out_voltage6_calibscale:26368
    out_voltage6_offset:-132608
    out_voltage6_raw:1792
    out_voltage6_scale:0.183105468
    out_voltage7_calibbias:18304
    out_voltage7_calibscale:26496
    out_voltage7_offset:-132608
    out_voltage7_raw:1920
    out_voltage7_scale:0.183105468
    out_voltage_powerdown:0
    uevent:MAJOR=249
    uevent:MINOR=2
    uevent:DEVNAME=iio:device2
    uevent:DEVTYPE=iio_device
    root@am57xx-evm:/sys/bus/iio/devices/iio:device2#

    Calibscale should be 65535 and calibbias should be 0 by default but it is not link that.

    if you try other values, do you still read 1024?

    yes i tried modifying this value it is not changing.

  • spi-max-frequency = <10000000>;

    10 Mhz is pretty high;

    triy 500 khz for testing; if it works, scale it up and see where it doesn't

  • triy 500 khz for testing; if it works, scale it up and see where it doesn't

    I changed it to 500khz but still the same issue.

  • Hi,

    Try enabling the SPI debugging feature in linux:

    - enable spi_debug from make menuconfig

    See if some error outputs from spidev are received when running dmesg after trying to write to one of the out_voltageX.

    If still nothing show up, can you post a waveform of an SPI write?

  • Hi,

    SPI debugging is already enabled. Following is the log of SPI devices

    oot@am57xx-evm:~# dmesg | grep spi
    [    2.531099] omap2_mcspi 480b8000.spi: registered master spi1
    [    2.531334] spi spi1.0: setup: speed 1000000, sample trailing edge, clk normal
    [    2.531347] spi spi1.0: setup mode 1, 8 bits/w, 1000000 Hz max --> 0
    [    2.531549] omap2_mcspi 480b8000.spi: registered child spi1.0
    [    2.531875] omap2_mcspi 480ba000.spi: registered master spi2
    [    2.532058] spi spi2.0: setup: speed 1000000, sample leading edge, clk normal
    [    2.532070] spi spi2.0: setup mode 0, 8 bits/w, 1000000 Hz max --> 0
    [    2.532272] omap2_mcspi 480ba000.spi: registered child spi2.0
    [    2.532390] spi spi2.1: setup: speed 1000000, sample leading edge, clk normal
    [    2.532401] spi spi2.1: setup mode 0, 8 bits/w, 1000000 Hz max --> 0
    [    2.532592] omap2_mcspi 480ba000.spi: registered child spi2.1
    [    3.424147] ads8688 spi2.0: Looking up vref-supply from device tree
    [    3.424153] ads8688 spi2.0: Looking up vref-supply property in node /ocp/spi@480ba000/ads8688_1@0 failed
    [    3.424186] ads8688 spi2.0: setup: speed 1000000, sample trailing edge, clk normal
    [    3.424532] ads8688 spi2.1: Looking up vref-supply from device tree
    [    3.424537] ads8688 spi2.1: Looking up vref-supply property in node /ocp/spi@480ba000/ads8688_2@1 failed
    [    3.424563] ads8688 spi2.1: setup: speed 1000000, sample trailing edge, clk normal
    [    3.424899] ad5360 spi1.0: Looking up vref0-supply from device tree
    [    3.424960] ad5360 spi1.0: Looking up vref1-supply from device tree
    root@am57xx-evm:~#

    No errors are seen, when we try to write to /sys/bus/iio/devices/iio\:device2/out_voltage0_raw

  • Hi,

    Can you tell us to what is SYNC connected? I see that SYNC is required to act as a CS, staying low for the duration of the write. IF SYNC does not go high after the 25th clock, transfer is considered corrupted and register won't update.

    Thanks

  • Hi,

    The issue is resolved after giving 10V vdd and -10V vss.

    initially we were giving 6V VDD and -6V vss

    thank you.