cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DH Accelerometer Interrupts

Cesco Gar
Associate II
Posted on February 20, 2017 at 17:55

Hi,

I have a problem to make interrupts (INT1 exactly) work with my LIS2DH12 Accelerometer.

What I am trying to do is to make the int1 trigger when there is a Y-axis high event (or low event).

I have setted all the required Registers for INT1 but it seems it is not working and I have even tried to look with an oscilloscope to see if it is doing something, but the results are still negative.

I have read some posts before making this one but the answers weren't helpful for me.

Can someone write down how they setted theirs interrupt registers to make them work correctly?

Some additional information:

1- I don't need the HPCF so I have deactivated it (I think it is deactivated by default, if I remember correctly)

2- The REGs I have changed are: CTRL_REG3, CTRL_REG4, INT1_CFG, INT1_THS, INT1_DUR

3- The temp and XYZ-axis are working correctly

Thank you for the help

#lis2dh

Note: this post was migrated and contained many threaded conversations, some content may be missing.
17 REPLIES 17
Posted on March 15, 2017 at 11:17

INT2_CFG register define which event will trigger the interrupt. For example if the bit XHIE is set the interrupt is triggered when the acceleration in X axis is higher then threshold.

H_LACTIVE

bit in

 CTRL_REG6

set the interrupt active level. By default the interrupt is active high (H_LACTIVE = 0), it means the level on interrupt pin is low and goes high when the interrupt occurs. 

Posted on March 16, 2017 at 09:24

I have set 

H_LACTIVE 

to 1, because I need that the signal is normally high so that when an interrupt triggers it goes low and I have set the interrupt to trigger on a YHIE.

I have a problem here, because the signal does exactly the reverse of what I am expecting:

When I have my board in a position that the Y-Axis readings are 0 the signal of INT2 is low and when I move the board and the reading rise the signal goes up. Shouldn't be the reverse? When I have the board at 0 Y-axis the signal should be high and when my reading rise and are higher than the threshold it should go low?

I am actually using your reg config for the int2 and I have deactivated the X/Z reading data and trigger events

Additional information: If I activate in the INT2_CFG YHIE the signal start low and goes high when I go above the threshold, if I activate YLIE the signal start high and goes low when I goabove the threshold, and if I activate both the signal never goes low.

Posted on March 16, 2017 at 12:30

Can you please double check your configuration of INT2_CFG register. Which value of INT2_CFG do you use to trigger the interrupt when it rise above the threshold?

My settings of the INT2_CFG = 0x04 was to trigger the interrupt when the value in Y axis is below threshold.
Posted on March 16, 2017 at 14:28

INT2_CFG = 0x04 as of now, and the signal starts high and goes low when I pitch the board, in both planes (+ and -).

If I set INT2_CFG 0x08 the signal starts low and goes high when I pitch the board, the same as before.

H_LACTIVE is set to 1.

If I have interpreted correctly the datasheet, when I have INT2_CFG 

0x08, it should trigger the interrupt only when I pitch the board higher than the threshold in the positive axis.

The strange thing is that if I read the INT2_SRC it gives back the result I am expecting, if I pitch the board in the positive plane it gives me back 0x08 and when I pitch in the negative plane it gives me back 0x04.

Accordingly to the settings, it should trigger the interrupt only when there is 0x08 and not when it is 0x04 too.

If you want I can screen the settings of the registers, if you don't trust me.

Additional information: The board is positioned so that the Y axis is 0 at the start. X & Z axis are deactivated.

Posted on March 17, 2017 at 09:25

I have an additional question, I am siorry if it is a bit offtopic, the FIFO interrupts work only on INT1?

Posted on March 17, 2017 at 11:34

I think there must be some misunderstanding, because the sensor really behaves as described in the datasheet.

Can you read the value of Y axis and evaluate themwith relation of interrupt status?

'If I have interpreted correctly the datasheet, when I have

INT2_CFG

=

0x08,

it should trigger the interrupt only when I pitch the board higher than the threshold in the positive axis.'

- The threshold is absolute value,so for example if the threshold is set to 0.5g the interruptwill be triggered by +0.6g and also by-0.6g.

Posted on March 17, 2017 at 11:39

I will write down my start-up sequence:

Write CTRL_REG1 ---------> 0x7F  (I activate all axis at 400 Hz LP)

Write CTRL_REG2 ---------> 0x00

Write CTRL_REG3 ---------> 0x00

Write CTRL_REG4 ---------> 0x80

Write CTRL_REG5 ---------> 0x00

Write CTRL_REG6 ---------> 0x21

Write REFERENCE ---------> 0x00

Write INT2_THS ---------> 0x20  (500 mG)

Write INT2_DUR ---------> 0x10

Write INT2_CFG ---------> 0x05  (XLIE & YLIE activated)

Write CTRL_REG5 ---------> 0x00

Gustavo Barboza
Associate
Posted on May 05, 2017 at 20:15

Hi, I have a problem to make interrupts too.

I tried to write in the registers but my library don't do that. Do you have a program in C that I can copy for to write in the registers?