完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
我目前正在测试安装在MKI151V1上的LIS2DH12加速度计。该板连接到NI的SPI / I2C设备,因为我想将传感器集成到labview测量软件中。首先,我想提一下,我是一个使用SPI的初学者,所以我可能犯了一个简单的错误。 在LabVIEW中,我首先打开SPI配置(设置片选,时钟速率,时钟极性,时钟相位),然后是读/写命令。在通信结束时,我再次关闭SPI配置。相应的R / W LabVIEW-VI需要一个十六进制数组作为输入,并在必要时以十六进制数组输出返回SPI从设备的答案。 LIS2DH12的每个命令都包含8位。因此,每个数组索引代表一个字节(十六进制格式)。 在读取的情况下,第一个数组索引表示读取命令(RW位; MS位;寄存器地址)。以下数组索引必须是我想要接收的寄存器数据的可选十六进制数。 在写入的情况下,第一个索引表示写入命令,以下索引表示我想在寄存器中写入的数据。 例如,当我想读取寄存器'WHO_AM_I'(0Fh)时:我发送输入数组'8Fh; 00h'(索引0;索引1)并接收输出数组'8Fh; 33h',这是正确答案这个登记册。到目前为止,一切正常。 最后我会谈到实际问题。如果我重复此读取命令,加速度计将以“FFh”回答。无论多个R / W命令之间的时间是什么,来自任何寄存器的每个R / W命令都会出现此问题。当我第一次连接传感器时,它也会响应'FFh'。 您有任何想法,这种行为的原因是什么? 有没有人有使用NI的SPI / I2C设备的经验? 我想提前感谢你。 最好的祝福, 帕斯卡尔 #lis2dh12#spi-communication #labview 以上来自于谷歌翻译 以下为原文 Hello, I'm currently testing the LIS2DH12 accelerometer, which is mounted on the MKI151V1. The board is connected to a SPI/I2C device from National Instruments because I want to integrate the sensor in a LabVIEW measurement software. First of all, I would like to mention, that I'm a beginner in working with SPI, so it is possible that I make a simple mistake. In LabVIEW, I first open a SPI configuration (Set Chip Select, Clock Rate, Clock Polarity, Clock Phase) followed by the Read/Write Command. At the end of the communication, I close the SPI configuration again. The corresponding R/W LabVIEW-VI needs an hex-array as input and returns the answer of the SPI-Slave, if necessary, in an hex-array output. Every command of the LIS2DH12 consists of 8bit. Thus every array index represents one byte (hex format). In case of a reading, the first array index represents the read command (RW bit; MS bit; register address). The following array indices have to be an optional hex-number for the number of register data I want to receive. In case of a writing, the first index represents the write command and the following indices represent the data I want to write in the register/s. As an example, when I want to read register 'WHO_AM_I' (0Fh): I send the input array '8Fh;00h' (index 0; index 1) and receive the output array '8Fh;33h', which is the right answer for this register. So far, everything works fine. Finally I will come to the actual problem. If I repeat this read command the accelerometer answers with 'FFh'. This problem occurs with every R/W-command from any register, no matter what time is in between multiple R/W-commands. When I connect the sensor for the first time, it also responds with 'FFh'. Do you have any ideas what the reason for this behavior is? Does anyone have some experience in working with the SPI/I2C device from National Instruments? I would like to thank you in advance. Best Regards, Pascal #lis2dh12 #spi-communication #labview |
|
相关推荐
1个回答
|
|
你控制CS引脚了吗?
我不完全确定NI设备真正做了什么。我认为它会在传输开始时将CS线设置为低,并在传输完成后再将其设置为高,如LIS2DH12手册中所述。 您可以通过示波器或逻辑分析仪捕获SPI总线上的通信吗? 是的,我会在接下来的几天内尝试这个。 以上来自于谷歌翻译 以下为原文 Do you control the CS pin? I'm not completely sure what the NI device really does. I think it sets the CS line to low, when the transmission starts and sets it high again after the transmission is finished, as described in the manual of the LIS2DH12. Can you capture the communication on SPI bus by a scope or logic analyzer? Yes, I will try this within the next days. |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2635 浏览 1 评论
3208 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1783 浏览 1 评论
3610 浏览 6 评论
5988 浏览 21 评论
939浏览 4评论
1316浏览 4评论
在Linux上安装Atollic TRUEStudio的步骤有哪些呢?
584浏览 3评论
使用DMA激活某些外设会以导致外设无法工作的方式生成代码是怎么回事
1303浏览 3评论
1359浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 23:40 , Processed in 1.097020 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号