完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
通过这样做,我已经能够使LIS3DSH为单个值工作:
transmitData [0] =(uint8_t)(LIS3DSH_READ | LIS3DSH_X_L); SPISend(transmitData,receiveData,2); xl = receiveData [1];但是如果我想在一个事务中读出多个值,我希望我可以这样做: transmitData [0] =(uint8_t)(LIS3DSH_READ | LIS3DSH_MULtiPLE | LIS3DSH_X_L); transmitData [1] =(uint8_t)(LIS3DSH_READ | LIS3DSH_X_L); SPISend(transmitData,receiveData,3); xl = receiveData [1]; xh = receiveData [2];或者字节2只是0xFF,因为自动增量会达到我的预期。 但是,唉,它不起作用。 (寄存器6中打开了地址增量) 可以这样做吗?我错过了什么? 现在需要文档,温度寄存器没有记录在数据表中。需要一段时间才能发现它是Celcius并偏向-25C。此外,M / S位也没有记录。我发现AN3393非常有用,数据表,不是那么多。 谢谢, 来自大白北的安德烈。 以上来自于谷歌翻译 以下为原文 I've been able to get the LIS3DSH working for single values by doing this: transmitData[0] = (uint8_t) (LIS3DSH_READ | LIS3DSH_X_L); SPISend( transmitData, receiveData, 2); xl = receiveData[1];But if I wanted to read out multiple values in one transaction, I'd expect that I could do something like: transmitData[0] = (uint8_t) (LIS3DSH_READ | LIS3DSH_MULTIPLE | LIS3DSH_X_L); transmitData[1] = (uint8_t) (LIS3DSH_READ | LIS3DSH_X_L); SPISend( transmitData, receiveData, 3); xl = receiveData[1]; xh = receiveData[2];Or have byte 2 just be 0xFF because the auto-increment would do what I expected. But alas, it doesn't work. (yes address increment is turned on in register 6) Can this be done? What am I missing? Now for documentation, the temperature register just isn't documented in the data sheet. It took a while to figure out that it is Celcius and biased by -25C. Also, the M/S bit isn't documented either. I found AN3393 to be very useful, the data sheet, not so much. Thanks, Andrei from The Great White North. |
|
相关推荐
5个回答
|
|
我假设您使用的是4线SPI接口,比多路读取操作方法更正确。但我不知道SPISend究竟能起什么作用。
最好用示波器或逻辑分析仪检查信号,看它是否与协议匹配。 以上来自于谷歌翻译 以下为原文 I assume you are using 4-wire SPI interface, than you approach for multi read operation is correct. But I don't know what exactly you function SPISend does. It would be good to check the signal with scope or logic analyzer to see if it match with the protocol. |
|
|
|
对不起,是的,你是对的,我正在使用4线SPI。
我的SPISend例程是: (uint8_t * transmit,uint8_t *收到,uint16_t 长度) { HAL_StatusTypeDef 状态; HAL_GPIO_WritePin(CS_I2C_SPI_GPIO_Port,CS_I2C_SPI_Pin, GPIO_PIN_RESET ); status = HAL_SPI_TransmitReceive(& hspi1,transmit,receive,length,100); HAL_GPIO_WritePin(CS_I2C_SPI_GPIO_Port,CS_I2C_SPI_Pin,GPIO_PIN_SET ); (状态!= HAL_OK ){ ( ''传输%d r n'',状态有问题); } } 当我发送两个字符时,模式是: 所以信号形式是可以的。在5.25 MBaud我没有嗡嗡声芯片。我正在获得的价值观是有意义的。 我检查了三字节版本上的波形(读取| multiple | xlow,read | xhigh,dummy)它看起来很好,没有违反,但数据没有改变。 安德烈 以上来自于谷歌翻译 以下为原文 Sorry, yes you are correct, I'm using 4 wire SPI. My SPISend routine is: (uint8_t * transmit, uint8_t * receive, uint16_t length) { HAL_StatusTypeDef status; HAL_GPIO_WritePin( CS_I2C_SPI_GPIO_Port, CS_I2C_SPI_Pin, GPIO_PIN_RESET ); status = HAL_SPI_TransmitReceive( &hspi1, transmit, receive, length, 100); HAL_GPIO_WritePin( CS_I2C_SPI_GPIO_Port, CS_I2C_SPI_Pin, GPIO_PIN_SET ); (status != HAL_OK ) { ( ''there is a problem with the transmit %drn'', status); } } When I send two characters the pattern is: So the signaling form is okay. At 5.25 MBaud I'm not buzzing the chip. The values that I'm getting out make sense. I checked the wave forms on the three byte version (read | multiple | xlow, read | xhigh, dummy) and it looked good, nothing violated, but the data did not change. Andrei |
|
|
|
好的,我明白了。
根据数据手册中的时序图,位0x80是R / W位,0x40是M / S位,位0x3F是地址位。 在现实生活中,没有M / S位。该图是来自上一代其他芯片的剪切/粘贴。 要读取多个字节,可以在控制器6中设置地址增量位,然后继续发送时钟。 如果将M位设置为0x40,则突然您只是读取其他寄存器。该器件的寄存器位于0x4x-0x7x范围内,您最终只能读取它们。 所以,这个片段有效: (uint8_t i = 0;我&lt; 7;我++){ transmitData = 0; } transmitData [0] =( uint8_t )(LIS3DSH_READ | LIS3DSH_X_L); SPISend(transmitData,receiveData,7); x =( int16_t )(receiveData [2]&lt;&lt; 8)| (int16_t )receiveData [1]; y =( int16_t )(receiveData [4]&lt;&lt; 8)| (int16_t )receiveData [3]; z =( int16_t )(receiveData [6]&lt;&lt; 8)| (int16_t )receiveData [5]; 来自大白北的安德烈 正如在embedded.fm播客和博客上看到的那样。 以上来自于谷歌翻译 以下为原文 Okay, I figured it out. According to the timing diagram in the data sheet, bit 0x80 is the R/W bit, and 0x40 is the M/S bit, with bits 0x3F being the address bits. In real life, there is no M/S bit. The diagram is a cut/paste from a previous generation of some other chip. To read multiple bytes, you set the address increment bit in control 6 and just keep sending clocks. If you set the M bit 0x40, suddenly you are just reading other registers. This device has registers in the 0x4x-0x7x range, and you just end up reading them. So, this snippet works: (uint8_t i = 0; i < 7; i++) { transmitData = 0 ; } transmitData[0] = ( uint8_t ) (LIS3DSH_READ | LIS3DSH_X_L); SPISend( transmitData, receiveData, 7); x = ( int16_t ) (receiveData[2] << 8) | (int16_t ) receiveData[1]; y = ( int16_t ) (receiveData[4] << 8) | (int16_t ) receiveData[3]; z = ( int16_t ) (receiveData[6] << 8) | (int16_t ) receiveData[5]; Andrei from The Great White North As seen on the embedded.fm podcast and blog. |
|
|
|
好的,在DocID022405 Rev 2中,表15显示了寄存器6的默认值,即地址递增关闭和水印中断打开。
第7.7节没有说明地址增量的默认值,但是水印中断是关闭的。 如果我没有设置地址增量位,地址仍会递增。 我认为文档有问题。 以上来自于谷歌翻译 以下为原文 Okay, in DocID022405 Rev 2, table 15 shows the default values for register 6 being address-increment being off and watermark interrupt being on. Section 7.7 says nothing about the default for address-increment, but has watermark interrupt being off. If I do not set the address-increment bit, the address still increments. I think there is something wrong with the documentation. |
|
|
|
我认为你是正确的图7,8,9,10,11
DocID022405 Rev 2(LIS3DSH数据表) 因为位1不是M / S而是寄存器地址的MSB,所以不正确。我请传感器专家确认并修复数据表。我在LSM6DSL的数据表中没有看到这个问题 关于CTRL_REG6的默认值,表15中没有提到它。我认为你将默认值误认为是寄存器地址的二进制表示。但是你在第7.7节中是正确的,没有提到ADD_INC的默认值。默认情况下,此位设置为1。 对不起给您带来不便。 以上来自于谷歌翻译 以下为原文 I think you are right the Figures 7, 8, 9, 10, 11 in DocID022405 Rev 2 (Datasheet for LIS3DSH) are not correct because the bit 1 is not the M/S but is MSB of the register address. I asked sensor specialists to confirm this and fix the datasheet. I don't see this issue in the datasheet for LSM6DSL Concerning the default value of CTRL_REG6, it is not mentioned in the table 15. I think you mistake the default value with binary representation of the register address. But you are right in the section 7.7 the default value of ADD_INC is not mentioned. This bit is set to 1 by default. I'm sorry for the inconvenience. |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2730 浏览 1 评论
3239 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1808 浏览 1 评论
3647 浏览 6 评论
6035 浏览 21 评论
1338浏览 4评论
198浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
350浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
442浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
273浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 00:12 , Processed in 1.642594 second(s), Total 85, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号