cancel
Showing results for 
Search instead for 
Did you mean: 

how to enable or disable free fall detection on LIS2DH12TR sensor? how to validate whether the interrupt is generated by free fall detection?

Mnago.1
Associate II

can you please provide the inputs ASAP, currently this task is at highest priority.

1 REPLY 1
Eleon BORLINI
ST Employee

Hi @Mnago.1​ ,

>> how to enable or disable free fall detection on LIS2DH12TR sensor?

You can check the application note AN5005 at p.26, where the free-fall configuration for the LIS2DH12 is described.

The pseudo-code for this embedded feature is the following one:

1. Write 57h into CTRL_REG1 // Turn on the sensor, enable X, Y, and Z, ODR = 100 Hz
2. Write 00h into CTRL_REG2 // High-pass filter disabled
3. Write 40h into CTRL_REG3 // Interrupt activity 1 driven to INT1 pad
4. Write 00h into CTRL_REG4 // FS = ±2 g
5. Write 08h into CTRL_REG5 // Interrupt 1 pin latched
6. Write 16h into INT1_THS // Set free-fall threshold = 350 mg
7. Write 03h into INT1_DURATION // Set minimum event duration
8. Write 95h into INT1_CFG // Configure free-fall recognition
9. Poll INT1 pad; if INT1 = 0 then go to 10 // Poll INT1 pin waiting for the free-fall event
10. (Free-fall event has occurred; insert your code here) // Event handling
11. Read INT1_SRC register // Clear interrupt request
12. Go to 9
//If you want to disable the free-fall recognition, write 00h into INT1_CFG

>> how to validate whether the interrupt is generated by free fall detection?

The INT1_CFG configuration is set so that for each axis (X, Y, Z) the cross of the threshold(s) in the high-to-low direction is activated and the 3 interrupts are combined in logic OR. An event that causes such a behavior is almost always a fall event.

If you are interested in a C code implementation for this embedded feature, although it is for another (similar) product, the LIS2DW12, you can check the C driver on Github here (lis2dw12_free_fall.c).

-Eleon