2014-01-13 09:35 AM
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,Travis2014-01-17 05:10 AM
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 ________________ Attachments : LSM303D.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzK9&d=%2Fa%2F0X0000000bJw%2FWpOSuxJO1H6JbZF_3ewf.JwN7UXXoGsuq.Zrlz7CRQY&asPdf=false