完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
寄存器配置如下所示,对应于LIS3DH的ctrl_reg 1-5。在配置之后我回读了ctrl_reg,结果是正确的,这意味着寄存器被编程为我想要的值。我期望的结果是我可以从OUT_X_L(28h) - OUT_Z_H(2Dh)获得12位数据。但结果是我只能从那些寄存器中获得8位数据。数据输出寄存器的MSB始终为零。我用来读取加速度数据的功能也在下面复制,其中i2c_read的最后一个参数为1 meas burst read。我想知道是什么问题阻止我获得12位输出数据。谢谢。
uint8_t ctrl_reg [5] = {/ *启用x,y,z加速度检测,正常模式,400HZ odr * / 0x77,/ *启用AOI1的高通滤波器* / 0x09,/ *在INT1上启用IA1 * / 0x40,/ *满刻度2g,高分辨率 0x08,/ * Fifo禁用* / 为0x00 }; void accel_read(int16_t * accel) { uint8_t buffer [6]; i2c_read(OUT_X_L,缓冲液,6,1); 加速度[0] =(缓冲液[1];&LT; 8)|缓冲器[0]; 加速度[1] =(缓冲液[3]&LT;&LT; 8)|缓冲液[2]; 加速度[2] =(缓冲液[5]&LT;&LT; 8)|缓冲液[4]; } 以上来自于谷歌翻译 以下为原文 The register configuration is as below array which corresponds to ctrl_reg 1-5 of LIS3DH. I read back the ctrl_reg after configure it, the result is correct which means the register is programmed to the value as I wanted. The result I expected is that I could get 12-bit data from OUT_X_L(28h) - OUT_Z_H(2Dh). But the result is I could only get 8-bit data from those registers. The MSB's of the data output registers are always zero. The function I am using to read the acceleration data is copied below as well, where the last parameter of i2c_read as 1 meas burst read. I'm wondering what the problem is to prevent me from getting 12-bit output data. Thanks. uint8_t ctrl_reg[5]= {/* Enable x,y,z accelaration detect, normal mode, with 400HZ odr */ 0x77,/* Enable high pass filter for AOI1 */ 0x09,/* Enable IA1 on INT1 */ 0x40,/* Full Scale 2g, high resolution 0x08,/* Fifo Disabled */ 0x00 };void accel_read(int16_t* accel) { uint8_t buffer[6]; i2c_read(OUT_X_L,buffer,6,1); accel[0]=(buffer[1]<<8)|buffer[0]; accel[1]=(buffer[3]<<8)|buffer[2]; accel[2]=(buffer[5]<<8)|buffer[4]; } |
|
相关推荐
2个回答
|
|
|
函数accel_read不正确(您不能在8位变量中向左移8位)。
尝试这个: 以上来自于谷歌翻译 以下为原文 The function accel_read is not correct (you can't shift left by 8 bits in 8 bit variable). Try this: |
|
|
|
|
|
请忽略这个帖子。我们使用的传感器是lis3de而不是lis3dh。因此,无法获得超过8位的分辨率。
以上来自于谷歌翻译 以下为原文 Please ignore this thread. The sensor we are using is lis3de in stead of lis3dh. So it's no way to get more than 8-bit resolution. |
|
|
|
|
只有小组成员才能发言,加入小组>>
stm32mp157的异核通信的rpmsg_sdb的m4固件和a7驱动该如何编写?
1472 浏览 0 评论
stm32f103用freertos对一个采样率为1kHz的传感器,进行采样,数据出差
1524 浏览 0 评论
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
3674 浏览 1 评论
3864 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
2483 浏览 1 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
752浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
685浏览 5评论
730浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
976浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
779浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-14 22:46 , Processed in 0.966349 second(s), Total 73, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2086