How to check if SPI is working?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to check if SPI is working?

跳至解决方案
13,662 次查看
giorgiopresciut
Contributor II

Dear NXP Community,

I'm trying to use the MCIMX6Q-SDB board to communicate with an ADC. The communication is via SPI.

The i.MX6 evaluation board has a DNP NOR FLASH located in U14. I've soldered there the 4 wires of the SPI to create the connection with the ADC.

The four signals:

- SPINOR_CLK

- SPINOR_MOSI

- SPINOR_MISO

- SPINOR_CS0

are correctly routed, I've checked the R590, R586, R584, R583 resistors and they are on position A.

The device tree is the 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 = <2500>;
     spi-max-frequency = <20000000>;
        };
};

The pin description of ecspi1 is the following:

pinctrl_ecspi1: ecspi1grp {
    fsl,pins = <
        MX6QDL_PAD_KEY_COL1__ECSPI1_MISO    0x100b1
        MX6QDL_PAD_KEY_ROW0__ECSPI1_MOSI    0x100b1
        MX6QDL_PAD_KEY_COL0__ECSPI1_SCLK    0x100b1
        MX6QDL_PAD_KEY_ROW1__GPIO4_IO09        0x1b0b0
    >;
};

When I try to communicate over SPI nothing happens. I see the clock select moving but no output on the MOSI. What's wrong with my configuration? Am I using the i.MX6 EVB correctly?

Thanks and regards

标签 (1)
标记 (4)
1 解答
10,624 次查看
Carlos_Musich
NXP Employee
NXP Employee

Hi Giorgio,

there are many thins that should be checked:

1. Enable SPI Driver by going to Device Drivers --> SPI Support and seting '*' to SPI device Driver, save changes and then exit.

pastedImage_1.png

Then make zImage and please note that you must not make imx_v7_defconfig  after you enabled spidev in menuconfig because .config may be lost.

2.  Check in your .dtsi file that adress-cells and size-cells are set on the ecspiX node

&ecspi1 {
    fsl,spi-num-chipselects = <1>;
    cs-gpios = <&gpio5 17 0>;
    pinctrl-0 = <&pinctrl_ecspi1>;
    pinctrl-names = "default";
    status = "disabled";

    spidev0: spi@0 {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "spidev";
        reg = <0>;
        spi-max-frequency = <2000000>;
    };
};
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

3. Verify that ecspiX is enabled in the .dts file (althoug you may enable ir in .dtsi the side effect is that all configurations will enable this feature)

&ecspi1 {
    status = "okay";
};‍‍‍

4. Verify that the pins you are using for SPI are not being repeated or used by other funtion in the device tree. In other words disable all other configs for

MX6QDL_PAD_KEY_COL1__xxx_xxx
MX6QDL_PAD_KEY_ROW0__xxx_xxx
MX6QDL_PAD_KEY_COL0__xxx_xxx
MX6QDL_PAD_KEY_ROW1__xxx_xxx

5. Once the i.MX boots you must see spidev0.0 listed under /dev, if you dont please rebuild zImage as indicated in step 1.

6. You can make a simple test with the command echo "hello" > /dev/spidev0.0  and you must see in oscilloscope the signals of the transfer.

7. If the problem persists you should double check hardware.


Regards,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

4 回复数
10,625 次查看
Carlos_Musich
NXP Employee
NXP Employee

Hi Giorgio,

there are many thins that should be checked:

1. Enable SPI Driver by going to Device Drivers --> SPI Support and seting '*' to SPI device Driver, save changes and then exit.

pastedImage_1.png

Then make zImage and please note that you must not make imx_v7_defconfig  after you enabled spidev in menuconfig because .config may be lost.

2.  Check in your .dtsi file that adress-cells and size-cells are set on the ecspiX node

&ecspi1 {
    fsl,spi-num-chipselects = <1>;
    cs-gpios = <&gpio5 17 0>;
    pinctrl-0 = <&pinctrl_ecspi1>;
    pinctrl-names = "default";
    status = "disabled";

    spidev0: spi@0 {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "spidev";
        reg = <0>;
        spi-max-frequency = <2000000>;
    };
};
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

3. Verify that ecspiX is enabled in the .dts file (althoug you may enable ir in .dtsi the side effect is that all configurations will enable this feature)

&ecspi1 {
    status = "okay";
};‍‍‍

4. Verify that the pins you are using for SPI are not being repeated or used by other funtion in the device tree. In other words disable all other configs for

MX6QDL_PAD_KEY_COL1__xxx_xxx
MX6QDL_PAD_KEY_ROW0__xxx_xxx
MX6QDL_PAD_KEY_COL0__xxx_xxx
MX6QDL_PAD_KEY_ROW1__xxx_xxx

5. Once the i.MX boots you must see spidev0.0 listed under /dev, if you dont please rebuild zImage as indicated in step 1.

6. You can make a simple test with the command echo "hello" > /dev/spidev0.0  and you must see in oscilloscope the signals of the transfer.

7. If the problem persists you should double check hardware.


Regards,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

10,624 次查看
dtvs
Contributor II

Hi Carlos,

I looked in to the menu config, and as suggested by you the "User mode  SPI device driver support" was not enabled.

After enabling I was able to see the SPI devices on the target!!!

Thank you!!!!

0 项奖励
回复
10,624 次查看
dtvs
Contributor II

Hi Carlos_Musich, thanks for the help.

We are able to see spidev in dev folder.

Thanks and regards.

0 项奖励
回复
10,624 次查看
giorgiopresciut
Contributor II

Hi Carlos,

many thanks for your help. SPI configured as dev is working. I see the "hello" word in the oscilloscope's monitor.

Regards,

Giorgio

0 项奖励
回复