Skip to main content
Visitor
August 13, 2026
Question

LIS2HH12 REFERENCE for high pass filter requires scaling?

  • August 13, 2026
  • 2 replies
  • 13 views

When setting high pass filter mode to HPM=01, the values in the reference registers (3Ah-3Fh) need different scaling compared to the data output registers (28h-2Dh). I am following the algorithm specified on p.18 of AN4662 using the following C code:

void accel_set_reference(void)
{
int16_t xyz[3];
lis2hh12_acceleration_raw_get(accel1, xyz); // extra dummy read
lis2hh12_acceleration_raw_get(accel1, xyz);
xyz[0] /= 8;
xyz[1] /= 8;
xyz[2] /= 8;
lis2hh12_xl_filter_reference_set(accel1, xyz);
lis2hh12_xl_filter_hp_bandwidth_set(accel1, LIS2HH12_HP_ODR_DIV_50_REF_MD);
lis2hh12_xl_filter_out_path_set(accel1, LIS2HH12_FILT_HP);
}

For some reason, I need to divide the raw acceleration values by 8 before setting them as the reference values.  Observe the graphs of acceleration data I obtain (the step change occurs when this function is called). First, without scaling down by 8:

Now when scaling down by 8:

Why is this scaling necessary? It is not documented anywhere (as far as I could find). I have full scale set to 2g. According to Table 13 of AN4662, the LSB value should be 0.061mg for 2g full scale, which is the same as the output data for 2g. Therefore, there should be no scaling necessary. Is there some config I might have missed that is causing this discrepancy?

2 replies

Federica Bossi
ST Technical Moderator
August 13, 2026

Hi ​@flamingfish ,

The /8 factor is needed because the LIS2HH12 output data are left-justified 16-bit values, while the high-pass filter reference uses its own reference-mode format. In practice, the raw acceleration value must be shifted right by 3 bits before writing it to the reference registers. AN4662 also states that the reference mode LSB is FS / 2^15, so with FS = 2g the scaling is still consistent; no extra full-scale configuration is missing.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
Visitor
August 13, 2026

Thank you for confirming the 3-bit shift.  I feel this should be documented more clearly. I still don’t see how FS/2^15 is correct, however, since 2g/2^15=0.061mg, which matches the LSB=0.061mg for the output data when FS=2g.  Perhaps it should say FS/2^12 (with Table 13 updated accordingly)?