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.

Linux/ADS7953EVM-PDK: Unable to read ADC output both in One-shot Mode and Continuous Mode

Part Number: ADS7953EVM-PDK
Other Parts Discussed in Thread: ADS7953, , ADCPRO, REF5025

Tool/software: Linux

Dear TI E2E Community,

I'm trying to get data out of my ADS7953 with no success. My setup is composed by:

- an i.MX6 EVB connected via SPI to the ADS7953 evaluation board (ADS7953EVM-PDK)

- a Freescale Linux image based on the following Kernel: 4.1.43-fslc+ga73554d

The driver of the ADS (ti-ads7950.c) is properly installed, I see the following hierarchy:

root@imx6qdlsabresd:~# ls -la /sys/bus/iio/devices/iio\:device0/
drwxr-xr-x    6 root     root             0 Jan  1  1970 .
drwxr-xr-x    4 root     root             0 Jan  1  1970 ..
drwxr-xr-x    2 root     root             0 Sep 29 09:30 buffer
-r--r--r--    1 root     root          4096 Sep 29 09:30 dev
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage0_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage10_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage11_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage12_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage13_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage14_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage15_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage1_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage2_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage3_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage4_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage5_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage6_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage7_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage8_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage9_raw
-rw-r--r--    1 root     root          4096 Sep 29 09:30 in_voltage_scale
-r--r--r--    1 root     root          4096 Sep 29 09:30 name
lrwxrwxrwx    1 root     root             0 Sep 29 09:30 of_node -> ../../../../../../../../../../firmware/devicetree/base/soc/aips-bus@02000000/spba-bus@02000000/ecspi@02008000/adc@0
drwxr-xr-x    2 root     root             0 Sep 29 09:30 power
drwxr-xr-x    2 root     root             0 Sep 29 09:30 scan_elements
lrwxrwxrwx    1 root     root             0 Sep 29 09:30 subsystem -> ../../../../../../../../../../bus/iio
drwxr-xr-x    2 root     root             0 Sep 29 09:30 trigger
-rw-r--r--    1 root     root          4096 Jan  1  1970 uevent

I tried to follow the instructions here with no success: http://processors.wiki.ti.com/index.php/Linux_Core_ADC_Users_Guide

When I try to execute a cat on channel #0 I got 0 as result, when I try to execute a cat on any other of the 11 channels I got:

root@imx6qdlsabresd:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage7_raw
cat: read error: Input/output error

I have configured the Kernel device tree as following:

&ecspi1 {
	fsl,spi-num-chipselects = <1>;
	cs-gpios = <&gpio4 9 0>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi1>;
	status = "okay";

        adc@0 {
 	compatible = "ti,ads7953";
 	reg = <0>;
 	#io-channel-cells = <1>;
 	vref-supply = <3000>;
 	spi-max-frequency = <20000000>;
        };
};

Is it ok to specify a vref of 3V? Is it ok to use an SPI frequency of 20MHz?

Thanks in advance for your help

EDIT: the vref is expressed in mV, since it's provided by the ADS7953EVM-PDK I'm not sure if the vref-supply field can be useful or not

Regards,

Fabio Emiliani

  • Fabio,

    >>>>>Is it ok to specify a vref of 3V? Is it ok to use an SPI frequency of 20MHz?

    ADS7953EVM-PDK has onboard 2.5V reference. This is the default option. Please check user manual
    www.ti.com/.../slau262

    20MHz SPI frequency is fine: ADS7953 can work with a maximum SPI frequency of 20MHz.

    >>>>>I tried to follow the instructions here with no success: processors.wiki.ti.com/.../Linux_Core_ADC_Users_Guide

    The instructions in the above link are for AM335x EVM and AM335x ADC Driver. It's not applicable to ADS7953EVM-PDK.

    We provide only Windows based ADCPro Software for this EVM.

    >>>>>My setup is composed by:
    - an i.MX6 EVB connected via SPI to the ADS7953 evaluation board (ADS7953EVM-PDK)
    - a Freescale Linux image based on the following Kernel: 4.1.43-fslc+ga73554d

    The ADS7953EVM-PDK consists of MMB0 mother board and ADS7953EVM. If you are hooking up to i.MX6 EVM, I suggest you connect the ADS7953EVM alone. Not with MMB0 board. MMB0 board already has a MCU on it and you don't want two SPI masters trying to access ADS7953. Please check ADS7953EVM-PDK user manual I referred above.

    >>>>The driver of the ADS (ti-ads7950.c) is properly installed

    Looks like this driver is developed and posted in the torvalds/linux github . You can check also with the original author of that.

    Thanks,
    Vishy
  • Hi Vishy, many thanks for your answer.

    I've removed the ADS7953EVM from the ADS7953EVM-PDK and tried to power-up it alone.

    From the datasheet of the EVB, chapter 4:
    P3 is the power-supply input connector. Table 5 lists the configuration details for P3. Only +5V analog and
    +5V digital is required to power the EVM. If desired, a jumper option (W6) is provided to supply the
    ADS7953 digital core with +3.3V.

    Regarding the analog supply I've connected a 5V to the P3.3 pin, ground on P3.6. Regarding the digital supply, is it needed?

    On chapter 5 I read:
    The ADS7953EVM has three sources for the reference voltage. Jumper W2 can select the REFP voltage
    from either the REF5025(U3) or from an external source applied to P1.18. Jumper W3 can select the
    REFM voltage from either the analog ground (AGND) or from an external source applied to P1.20.

    W2 is configured to generate the reference voltage by the use of the REF5025. Is this voltage generated by the digital supply mentioned in the chapter 4?

    Regards,
    Fabio
  • >>>>Regarding the analog supply I've connected a 5V to the P3.3 pin, ground on P3.6. Regarding the digital supply, is it needed?

    Yes digital supply is needed. Logic level should be the same as the freescale MCU you are connecting to.

    >>>W2 is configured to generate the reference voltage by the use of the REF5025. Is this voltage generated by the digital supply mentioned in the chapter 4?

    No. The +5V supply provided to P3.3 pin also powers REF5025. For REFP, use the VREF+ from U3 (REF5025) and for REFM, leave it connected to AGND.

    ADS795x needs a digital supply on +VBD pin for I/O and SPI communication.

    Thanks,
    Vishy
  • Many thanks for your info, I've added both the analog and digital power supply as per described in the datasheet. REF5025 is the source of the reference voltage.

    The last doubt regarding wiring connections is related to the clock select. In the datasheet there are two options:
    - PIN name CNTL -> Signal name: CS
    - PIN name FSX -> Signal name: FSYNC Xmit

    Which is the difference between the CS and FSYNC Xmit? Which signal do I have to use as clock select?

    Thanks and regards,
    Fabio
  • Fabio,
    Please check link below

    e2e.ti.com/.../620182

    There's a photo of the EVM with all the connections to double check. CS is chip select and FSYNC is frame sync signal of DSPs. I don't think Freescale will have a frame sync signal (like old DSPs) for SPI communication. So use CS option for W5 as shown in the photograph of the link above. Basically the whole SPI communication can take place only when CS is asserted. All the SPI signals are active only during active CS period.

    Thanks,
    Vishy
  • Hi Vishy,
    I've checkt the link, all the wirings are correctly connected. I've also started to use the CS option for W5.

    During the last days I've checked the SPI functionalities on i.MX6 side. EVerything is working fine. I've disconnected the TI ADC anche checked with the oscilloscope if the i.MX6 is correctly mastering the SPI bus. It is, I can see all the expected signals.

    I think the problem can be somewhere between the device tree and the TI driver. Still struggling... any ideas?

    Regards,
    Fabio
  • Fabio,
    Whatever SPI port/GPIOs (especially CS) of i.MX6 you have connected to ADS7953 should also be registered in the Linux kernel tree so they are correctly configured with permissions.
    Do you have any other SPI devices working?
    Thanks,
    Vishy
  • No, I don't have any other SPI working. I've checked the device tree and seems fine.

    Yesterday I have noticed a strange error immediatly after the probe of the driver:

    ti_ads7950_probe
    /soc/aips-bus@02000000/spba-bus@02000000/ecspi@02008000/adc@0: could not find phandle

    What does it mean? Why the pointer to the adc node can't be found?

    Regards,

    Fabio

  • Fabio,
    I will check about this. Meanwhile suggest you check about this in the iMx6 community. I see active discussions on linux spi drivers there. Google iMx6 linux spi driver.
    Thanks,
    Vishy
  • Hi Vishy,

    the problem was caused by a wrong description of the ADC in the device tree. See the following binding:

    * Texas Instruments ADS7950 family of A/DC chips
    
    Required properties:
     - compatible: Must be one of "ti,ads7950", "ti,ads7951", "ti,ads7952",
       "ti,ads7953", "ti,ads7954", "ti,ads7955", "ti,ads7956", "ti,ads7957",
       "ti,ads7958", "ti,ads7959", "ti,ads7960", or "ti,ads7961"
     - reg: SPI chip select number for the device
     - #io-channel-cells: Must be 1 as per ../iio-bindings.txt
     - vref-supply: phandle to a regulator node that supplies the 2.5V or 5V
       reference voltage
    
    Recommended properties:
     - spi-max-frequency: Definition as per
    		Documentation/devicetree/bindings/spi/spi-bus.txt
    
    Example:
    adc@0 {
    	compatible = "ti,ads7957";
    	reg = <0>;
    	#io-channel-cells = <1>;
    	vref-supply = <&refin_supply>;
    	spi-max-frequency = <10000000>;
    };
    

    Since the vref is generated by the ADS7953EVM-PDK and not by the i.MX6 EVB there is no need of a "refin_supply". So I have created  a dummy regulator and specified it in that field. The phandle error has disappeared.

    I made futher steps in the debug. As of now I see the CS, CLK and MOSI signals moving correctly but the MISO is still unresponsive. I can't get any output from the ADC. I hope to come back soon with a solution

    --

    Fabio

  • Fabio,

    Thanks for the update.

    Please note the ADS7953 has a 2 cycle delay on start-up... In "cycle N" you tell it which channel to switch to in "cycle N+1" and then the conversion of that is given in "cycle N+2".

    As an example,  below I send 0x1880, 0x1900, and 0x1980 to read data in manual mode from channel 1, channel 2 and channel 3. Channel 1 input = 1.25V, Channel 2 = channel 3 = 0.625V. See below logic analyzer capture of SPI exchange between ADS795x and MSP430: channel 1 data comes out in 3rd frame, channel 2 data comes out in 4th frame and channel 3 data comes out in 5th frame.

    Thanks,

    Vishy

  • Hi Vishy,

    I know the ADS7953 has a 2 cycle delay on start-up. That's how the driver behaves:

    /*
     * Setup default message. The sample is read at the end of the first
     * transfer, then it takes one full cycle to convert the sample and one
     * more cycle to send the value. The conversion process is driven by
     * the SPI clock, which is why we have 3 transfers. The middle one is
     * just dummy data sent while the chip is converting the sample that
     * was read at the end of the first transfer.
     */
    st->scan_single_xfer[0].tx_buf = &st->tx_buf[0];
    st->scan_single_xfer[0].len = 2;
    st->scan_single_xfer[0].cs_change = 1;

    st->scan_single_xfer[1].tx_buf = &st->tx_buf[0];
    st->scan_single_xfer[1].len = 2;
    st->scan_single_xfer[1].cs_change = 1;

    st->scan_single_xfer[2].rx_buf = &st->rx_buf[0];
    st->scan_single_xfer[2].len = 2;

    spi_message_init_with_transfers(&st->scan_single_msg, st->scan_single_xfer, 3);

    When I execute a raw read, e.g.:

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

    I see on the MOSI the exchages of three 16bit words. The first burst is the following:

    0001 1 0000 1 0 0 0000 = 0x1840

    that means:

    DI15-12: 0001 = Selects manual mode

    DI11: 1 = Enables programming of bits DI06 through DI00

    DI10-07: 0000 = channel-0

    DI06: 1 = Selects 5-V input range

    DI05: 0 = Device normal operation (no power down)

    DI04: 0 = The SDO pin outputs the current channel address of the channel on bits DO15 through DO12 followed by a 12-bit conversion result on bits DO11 through DI00

    DI03-00: 0000 = The GPIO data for the channels configured as an output

    The second burst is the same, the driver sends out again the same payload.

    The third burst is composed by all zeros, the driver expects the result of the conversion operation from the MISO.

    See the following images:

    That's an overview of the raw read, in yellow the clock, in blue the MOSI:

    below a zoom on the first burst, the 0x1840 word:

    then the zoom of the second burst, again the 0x1840 word:

    finally the third word, all zeros (that's when I expect the conversion result from the MISO):

    Questions:

    - Is the driver behaviour correct? Is it ok to send twice the same 16bit word (0x1840)?

    - After the device power up I don't do any configuration, do I need to configure something to work in manual mode? Can I directly send out the 0x1840 word to read from channel-0?

    Thanks in advance for your time

    Regards,

    Fabio

  • Fabio,

    >>> Is the driver behaviour correct? Is it ok to send twice the same 16bit word (0x1840)?

    Looks to me the driver behavior is fine. It is ok to send twice the same 16bit word (0x1840). Since Channel 0 is selected in frame 1 and frame 2, channel 0 data is read out in frame 3 as well as in frame 4. As the driver automatically makes 3 transfers, you should see channel 0 data read out at the end of 3rd transfer.

    >>>After the device power up I don't do any configuration, do I need to configure something to work in manual mode? Can I directly send out the 0x1840 word to read from channel-0?

    Yes, you can directly send out the 0x1840 to read from channel-0. For manual mode, there are no program registers. You don’t need any other configuration to work in manual mode.

    Thanks,
    Vishy
  • Hi Vishy,

    thanks for the confirmations.

    I have still the following doubts:

    - the level of my MOSI signal is idle high, your MOSI is idle low. Is it ok?

    - can you confirm that the SPI mode to be used with the ADS7953 is the SPI_MODE_0 (CPOL=0, CPHA=0)?

    - I don't understand the description of the bit DI11, in the datasheet I read:

    1 -> Enables programming of bits DI06 through DI00

    0 -> Device retains values of bits DI06 through DI00 from the previous frame

    What happens if I set DI11 to 1? Is the value of DI06 ignored on behalf of the value of DI0 (GPIO0)?

    Since I would like to specify the value of DI06 manually (I'm interested about the 5-V input range -> DI06 = 1), which value do I have to specify for DI11?

    Thanks and regards,

    Fabio

  • Fabio,

    >>>>can you confirm that the SPI mode to be used with the ADS7953 is the SPI_MODE_0 (CPOL=0, CPHA=0)?
    Yes, for the ADS795x, you should be able to run with SPI mode 0 (CPOL = 0, CPHA = 0). FYI, ADS795x devices expect settled DIN data at SCLK rising edge. Your scope screenshot shows SDI settled during SCLK rising edge.

    >>>What happens if I set DI11 to 1? Is the value of DI06 ignored on behalf of the value of DI0 (GPIO0)?

    No. Value of DI06 is not ignored on behalf of the of DI0.

    When DI11 is set as 1, bits DI06, DI05, DI04, ..., DI00 can be programmed by the user. Basically it enables programming of 'range and GPIO'. So, for example, when you write DI06 as 1, then 5V input range is selected. When you write DI05 as 1, device powers down on 16th SCLK falling edge and so on.

    Let me know if this is not clear.

    Thanks,
    Vishy
  • Ahhh, ok, I have badly interpreted the datasheet. Thanks for the clear explanation.

    Yesterday I tried to follow with a multimeter the power supplies. In detail I tried to check VCC_D on J2. I have no jumper installed so J2 is not connected to ground, I expect a 5V but I've got less then 1V. It seems like if the ADS7953 is pulling down the voltage (GPIO2, GPIO3 inputs). I have asked to the hardware guys to check if the component is broken or not.

    I'll keep yuo updated, again many thanks for your help

    Regards,

    Fabio