araobp / spielzeug

Internet of Robots
1 stars 0 forks source link

12 bit data in those registers (MSB/LSB total 16bit) of HMC5883L is 2's complement form #10

Closed araobp closed 7 years ago

araobp commented 7 years ago

According to the data sheet http://akizukidenshi.com/download/ds/honeywell/HMC5883L_3-Axis_Digital_Compass_IC.pdf, the data range of those registers (x, y, z) is from 0xf800 to 0x7fff in 2's complement form (16bit), which means -2048(0xf800) to +2047(0x7fff).

So the operation "msb << 8 & 0xff00 | lsb" in the sample code does not seem to be sufficient.

araobp commented 7 years ago

Arduino Uno: int is 16bit length. ESP8266: int is 32bit length.

The sample code may be correct, but it should have used uint_16.