openimu300ZI evk 如何使用spi模式读取数据 SPI reading of Open-IMU300ZI_evk

使用树莓派3B,spidriver-c以及这份驱动代码,evk的p1上的三个跳线帽均已拔掉,已连接SPI(MOSI,MISO,CLK,NSS) lines, 1PPS line, VCC,GND。data ready line线在树莓派上未找到对应管脚故未连接,使用逻辑分析仪查看树莓派发送一切正常,MISO未返回任何数据?eded353629cf79008063715bae8f882.png

Timing request of 300 SPI: MUST BE

7a5a1c25-a940-481a-a535-41e92c8a5356-image.png

@sunshine1995tangyao 非常感谢分享!

@cek 使用wiringPiSPIDataRW函数进行读写是按照8位读写,但是openimu的spi按照16位读写,源代码中发送0x5600 0x0000时分别调用了两次该函数,导致发送完一次后CS线处于HIGH,因此直接调用一次该函数发送四字节,可以实现16位读写,但是会多一个时钟(Using the wiringPiSPIDataRW function to read and write is based on 8 bits, but openimu's SPI is based on 16 bits. When sending 0x5600 x0000 in the source code, the function is called twice respectively, resulting in the CS line at high after sending once. Therefore, calling the function once to send four bytes directly can realize 16 bit read and write, but there will be one more clock:):
buf[0] = REG_PRD;
buf[1] = 0x00;
buf[2] = 0x00;
buf[3] = 0x00;
wiringPiSPIDataRW(PI_SPI_CHANNEL,buf,4);
0063a8fdfd223ef48bbe52318b3bae9.png dfd312e548a42b59a005cde3f95914f.png

@sunshine1995tangyao 能把你的SPI问题的原因, 解决方法,分享出来吗? 以帮助我们的所有开发者,谢谢。
最好中英,对照。

could you share what is the problem you met in SPI communiction? how did you figure out it and working well now? thanks for your information which will be good helpful for all developers.

十分感谢!您的建议帮助很大,已解决问题~~

keep ENABLE line always low during request and feedback period. 在寄存器请求和获得反馈的时间段内, ENABLE线要保持拉低一直, 就是CS线在IMU300这个SLAVE被选中时要保持LOW.

Hi vvhahaha, tangyao,
Github上面那个 spidriver-c是IMU381 在树莓派上的驱动,由于OpenIMU处理器和IMU381处理器主频有差异,所以SPI timing会有差异,请参考
https://openimu.readthedocs.io/en/latest/software/SPImessaging.html
有问题请随时提出

@Li YiFan spi有任何接线和软件上的其他设置吗?

Log in to reply