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

  • 0
    •  Analog Employees 
    on Oct 19, 2020 5:50 AM 1 month ago

    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;

  • 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?

  • 0
    •  Analog Employees 
    on Oct 23, 2020 8:29 AM 1 month ago in reply to VKumar592
    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.

  • 0
    •  Analog Employees 
    on Oct 27, 2020 8:38 AM 28 days ago in reply to VKumar592
    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