Hi, I agree with you about the dig_xyz1 trim register that its unsigned 16 bit int acording to the document, but on the other hand, the function that extracts the trim registers from the BMM150-Sensor-API is: static int8_t read_trim_registers(struct bmm150_dev *dev) { int8_t rslt; uint8_t trim_x1y1[2] = { 0 }; uint8_t trim_xyz_data[4] = { 0 }; uint8_t trim_xy1xy2[10] = { 0 }; uint16_t temp_msb = 0; /* Trim register value is read */ rslt = bmm150_get_regs(BMM150_DIG_X1, trim_x1y1, 2, dev); if (rslt == BMM150_OK) { rslt = bmm150_get_regs(BMM150_DIG_Z4_LSB, trim_xyz_data, 4, dev); if (rslt == BMM150_OK) { rslt = bmm150_get_regs(BMM150_DIG_Z2_LSB, trim_xy1xy2, 10, dev); if (rslt == BMM150_OK) { /* Trim data which is read is updated * in the device structure */ dev->trim_data.dig_x1 = (int8_t)trim_x1y1[0]; dev->trim_data.dig_y1 = (int8_t)trim_x1y1[1]; dev->trim_data.dig_x2 = (int8_t)trim_xyz_data[2]; dev->trim_data.dig_y2 = (int8_t)trim_xyz_data[3]; temp_msb = ((uint16_t)trim_xy1xy2[3]) << 8; dev->trim_data.dig_z1 = (uint16_t)(temp_msb | trim_xy1xy2[2]); temp_msb = ((uint16_t)trim_xy1xy2[1]) << 8; dev->trim_data.dig_z2 = (int16_t)(temp_msb | trim_xy1xy2[0]); temp_msb = ((uint16_t)trim_xy1xy2[7]) << 8; dev->trim_data.dig_z3 = (int16_t)(temp_msb | trim_xy1xy2[6]); temp_msb = ((uint16_t)trim_xyz_data[1]) << 8; dev->trim_data.dig_z4 = (int16_t)(temp_msb | trim_xyz_data[0]); dev->trim_data.dig_xy1 = trim_xy1xy2[9]; dev->trim_data.dig_xy2 = (int8_t)trim_xy1xy2[8]; temp_msb = ((uint16_t)(trim_xy1xy2[5] & 0x7F)) << 8; //This line takes only the 7 LSB from that register dev->trim_data.dig_xyz1 = (uint16_t)(temp_msb | trim_xy1xy2[4]); } } } return rslt; } The function takes only the 15bit LSB of those two bytes, so what should i do? Best Regards, Jason
... View more