cancel
Showing results for 
Search instead for 
Did you mean: 

Read acceleration values at the time of interrupt generation

AB.4
Associate II

Hello ST Community,

I am using LIS2DH12 sensor for the following purpose: 

  1. Generate an interrupt when the acceleration exceeds 1.7 g in any axes and read the x, y and z-axis values after the interrupt is generated. 
  2. Generate an interrupt when the acceleration goes below 350 mg in all axes and read the x,y and z-axis values after the interrupt is generated.
  3. Wakeup when the threshold is above 256 mg.

For this purpose, I have set the registers as follows:

CTRL_REG1 - 0x37

CTRL_REG3 - 0x40

CTRL_REG4 - 0x88

CTRL_REG5 - 0x0A

CTRL_REG6 - 0x28

INT1_THS - 0x0B

INT1_DUR - 0x0B

INT1_CFG - 0x95

INT2_THS - 0x38

INT2_DUR - 0x01

INT2_CFG - 0x2A

ACT_THS - 0x05

ACT_DUR - 0x20

When an interrupt occurs (INT1 or INT2), in the interrupt handler, I read OUT_X, OUT_Y, OUT_Z registers to get the acceleration value. If INT1 occurs, I was expecting the acceleration value to be less than 350 mg but there are cases when the acceleration read is higher than this. Same is the case with INT2. If INT2 interrupt occurs, the read acceleration value is less than 1.7 g in some cases. 

  1. What could be the possible reason for this?
  2. For the purpose of reading the acceleration value when the interrupt occurs, do you recommend specific settings for the control registers (maybe having a FIFO mode instead of bypass mode)?

Regards,

Anusha

1 REPLY 1
Eleon BORLINI
ST Employee

Hi Anusha @AB.4​ ,

Your configuration looks ok at first glance.

You may try not to latch the interrupts in CTRL_REG5 (24h) configuration and see what happens...

I'm wondering if you are effectively reading the acceleration value that triggered the interrupt when you run your procedure, or you are actually receiving a subsequent value . Especially for the INT2, the interrupt duration is low (1/ODR). I would suggest you to use the device in FIFO mode, so that you can compare some "historical" acceleration values around the interrupt.

You can find and example of FIFO configuration in the application note AN5005, or for demo code you can see the Github example: lis2dh12_read_fifo.c.

-Eleon