AnsweredAssumed Answered

imx8qxp spi 测试问题

Question asked by 一笑 独孤 on Jun 11, 2020
Latest reply on Jun 12, 2020 by 一笑 独孤

imx8qxp-mek开发板 跳接R1222,R1223,R1224,R1225,四颗电阻,把SPI0接到基本的J26端口。把J26端口的MISO和MOSI外部短接,使用spidev_test.c做自发自收测试。结果不正确。

命令行输入和输出如下:

root@imx8qxpmek:~# ./spitest -D /dev/spidev0.0 -p "123\xde\xad" -v -O -H
spi mode: 0x3
bits per word: 8
max speed: 5000000 Hz (5000 KHz)
TX | 31 32 33 DE AD __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | 123蕲
RX | 03 83 3C 8C 0E __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | .

root@imx8qxpmek:~# ./spitest -D /dev/spidev0.0 -p "123\xde\xad" -v -O -H
spi mode: 0x3
bits per word: 8
max speed: 5000000 Hz (5000 KHz)
TX | 31 32 33 DE AD __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | 123蕲
RX | 03 83 3C 8C 0E __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | .

root@imx8qxpmek:~# ./spitest -D /dev/spidev0.0 -p "123\xde\xad" -v -O -H
spi mode: 0x3
bits per word: 8
max speed: 5000000 Hz (5000 KHz)
TX | 31 32 33 DE AD __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | 123蕲
RX | C3 87 3C 8C 0C __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | 脟<

root@imx8qxpmek:~# ./spitest -D /dev/spidev0.0 -p "123\xde\xad" -v -O -H
spi mode: 0x3
bits per word: 8
max speed: 5000000 Hz (5000 KHz)
TX | 31 32 33 DE AD __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | 123蕲
RX | 06 87 3C 8C 0E __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | .

dts配置如下:

&iomuxc {
 imx8qxp-mek {
  pinctrl_lpspi0: lpspi0grp {
   fsl,pins = <
    SC_P_SPI0_SCK_ADMA_SPI0_SCK  0x0600004c
    SC_P_SPI0_SDO_ADMA_SPI0_SDO  0x0600004c
    SC_P_SPI0_SDI_ADMA_SPI0_SDI  0x0600004c
    SC_P_SPI0_CS0_ADMA_SPI0_CS0   0x0600004c
   >;
  };
 };
};

&lpspi0 {
 #address-cells = <1>;
 #size-cells = <0>;
 fsl,spi-num-chipselects = <1>;
 pinctrl-names = "default";
 pinctrl-0 = <&pinctrl_lpspi0 >;
 status = "okay";
 spidev0: spi@0 {
  reg = <0>;
  compatible = "rohm,dh2228fv";
  spi-max-frequency = <5000000>;
 };
};

Outcomes