Hi Isaac @IC.1 ,
>> For example, it states in the data sheet that low power mode has an 8 bit data output.
I assume that this means registers LIS2DH_OUT_X_L and LIS2DH_OUT_X_H are 8 bits each, and I can read the raw accelerometer data into a 2 byte integer.
Your statement about the low power is correct: in this case the only register to be considered is the MSB, i.e. the LIS2DH_OUT_X_H one. You have, in general, to concatenate the two registers and consider only the first 8 bits (for LP mode), 10 bits (for NM mode) and 12 bits (for HR mode), as defined in the datasheet.
Taking as example the FS +-2g, you can refer to the C drivers on Github (lis2dh_reg.c:( concatenate the two registers, convert the value into decimal via two's complement, shift the bits (divide by 2^8=256) and multiply for the sensitivity, i.e. 16mg/LSB in this case.
float_t lis2dh_from_fs2_lp_to_mg(int16_t lsb)
{
return ((float_t)lsb / 256.0f) * 16.0f;
}
>> Given that the high resolution mode has a 12 bit data output, it would mean that I need 3 bytes to get all the data. It would also mean that I need to read from another register (besides low and high registers), which I don't see specified. Therefore, I believe my thought process is wrong.
Check please the comment above, and consider the following conversion formulas:
float_t lis2dh_from_fs2_hr_to_mg(int16_t lsb)
{
return ((float_t)lsb / 16.0f) * 1.0f;
}
In normal mode only the first 10 bits have to be considered, and the conversion formula is the following one:
float_t lis2dh_from_fs8_nm_to_mg(int16_t lsb)
{
return ((float_t)lsb / 64.0f) * 16.0f;
}
If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster.
-Eleon