I am trying to calculate the heading of the 3 axis compass and stuck with this issue that I can't solve. when I read the compass output register viz.

0x03 (x_msb), 0x04 (x_lsb),

0x05 (z_msb), 0x06 (z_lsb),

0x07 (y_msb) and 0x08 (y_lsb).

the x,y and z MSB values are not updated at all where as y and z LSB are updated as expected. I configured the

CRA_REG_M (00h) to 0x10 for 30Hz ODR,

MR_REG_M (02h) to 0x00 for continuous mode and

CRB_REG_M (01h) to every possible value of (GN2,GN1,GN0) for all sensor range

but had same result. I can't understand what the problem is, The I2C software seems to be fine as it works perfectly for accelerometer and gyro!!!!.

did anyone come across this issue????

sample output:

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=23

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=23

please note the Mxh, Myh and Mzh won't buzz however I rotate or move the compass.

0x03 (x_msb), 0x04 (x_lsb),

0x05 (z_msb), 0x06 (z_lsb),

0x07 (y_msb) and 0x08 (y_lsb).

the x,y and z MSB values are not updated at all where as y and z LSB are updated as expected. I configured the

CRA_REG_M (00h) to 0x10 for 30Hz ODR,

MR_REG_M (02h) to 0x00 for continuous mode and

CRB_REG_M (01h) to every possible value of (GN2,GN1,GN0) for all sensor range

but had same result. I can't understand what the problem is, The I2C software seems to be fine as it works perfectly for accelerometer and gyro!!!!.

did anyone come across this issue????

sample output:

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=20

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=23

Mxh=-16 Mxl=0 Myh=-1 Myl=35 Mzh=-1 Mzl=23

please note the Mxh, Myh and Mzh won't buzz however I rotate or move the compass.

However the solution is simple, just select the least sensitivity. I selected the value 0xE0 for 0x02 register and it worked :)