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.

L138 SPI write/ read problem

Linux 下编程,按照以下方式编程控制SPI读、写。

打开设备

spi_fd = open( "/dev/spidev1.0" , O_RDWR);

写操作

uint8_t *txVal;

ret = write(spi_fd, txVal, 1); 

读操作

uint8_t rxVal[3];

ret = read(spi_fd, &rxVal, 3);

现在的问题是,写一个8位数,测到的SCLK信号为8个脉冲,等几个周期又来8个脉冲。同时测数据信号,8位数据对应的是第一轮8个脉冲。给人的感觉是SPI发送了两个8bit数,一个是我需要发的,一个是0x00。

读操作就更奇怪了,读24位数,回来的是8个脉冲,然后32个脉冲信号。如果是读8bit数,就是8+16个脉冲。

这种现象是否正确?有哪位大虾碰到过,怎么解决的?