ST意法半导体
直播中

李渔滢

7年用户 246经验值
私信 关注
[问答]

LSM303D数据同步

我见过的所有示例代码都通过轮询相应的寄存器来读取加速度和磁场值。
例如:
x.l = i2c_read(OUT_X_L_A);
x.h = i2c_read(OUT_X_H_A);

y.l = i2c_read(OUT_Y_L_A);

y.h = i2c_read(OUT_Y_H_A);

z.l = i2c_read(OUT_Z_L_A);

z.h = i2c_read(OUT_Z_H_A);


传感器何时更新寄存器值?我怎么知道何时读取寄存器?
我担心芯片可以在轮询OUT_X_L_A和OUT_X_L_H之间更新寄存器值,从而导致读取损坏。


谢谢,
特拉维斯

以上来自于谷歌翻译


以下为原文





All the example code I've seen reads the acceleration and magnetic field values by polling the appropriate registers.
For example:
x.l = i2c_read(OUT_X_L_A);
x.h = i2c_read(OUT_X_H_A);

y.l = i2c_read(OUT_Y_L_A);

y.h = i2c_read(OUT_Y_H_A);

z.l = i2c_read(OUT_Z_L_A);

z.h = i2c_read(OUT_Z_H_A);



When does the sensor update the register values? How do I know when to read the registers?
I am concerned that the chip could update the register value between polling the OUT_X_L_A and OUT_X_L_H, resulting in a corrupt reading.


Thanks,
Travis

回帖(1)

张鑫

2019-5-29 15:55:04
特拉维斯你好,
 
 
 为避免出现此类问题,请在附件数据表中查看以下参数:
 
 CTRL1(20h) - BDU参数
 
 BDU阻止加速和磁数据的数据更新。默认值:0(0:连续更新; 1:输出寄存器未更新,直到读取了MSB和LSB)。
非常感谢你,
 
 
 蒂亚戈

以上来自于谷歌翻译


以下为原文





Hello Travis,


In order to avoid an issue like this, please check on the attached datasheet the following parameters:

CTRL1 (20h) - BDU Parameter

BDU Block data update for acceleration and magnetic data. Default value: 0 (0: continuous update; 1: output registers not updated until MSB and LSB have been read).  
Thank you very much,


Thiago
举报

更多回帖

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