ST意法半导体
直播中

张大妍

8年用户 192经验值
私信 关注
[问答]

LIS3DH无法按预期输出12位高性能分辨率

寄存器配置如下所示,对应于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];< 8)|缓冲器[0];
加速度[1] =(缓冲液[3]<< 8)|缓冲液[2];
加速度[2] =(缓冲液[5]<< 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)

曾玲娟

2019-4-10 07:30:30
函数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:
举报

张大妍

2019-4-10 07:39:52
请忽略这个帖子。我们使用的传感器是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.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分