cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DH12 Double Click Interrupt

Chithambaram Veerappan
Associate II
Posted on January 04, 2017 at 18:13

Hi All

I am having some difficulties in configuring the Double Click Interrupt on the LIS2DH12.

After power up, I am doing the following:

TEMP_CFG_REG = 0xC0

CTRL_REG4 = 0x80

CTRL_REG1 = 0x77

The above seems to work and provides sensible values for xyz axis when the PCB is at various angles. This suggests that the I2C bus is functioning correctly. 

Next I would like to enable click detection in the y- axis (any axis would do to start to prove the function works). I would like an interrupt on INT1 when a double click has occurred. INT1 is pulled up to 3.3 V via a 100 kOhm resistor.

I am doing the following in order to configure the Double Click feature

CTRL_REG3 = 0x80

CLICK_CFG = 0x08

CLICK_THS = 0x88

TIME_LIMIT = 0xFF

 //Not really sure the purpose of this, the datasheet is not really clear

TIME_LATENCY = 0xFF

 //Not really sure the purpose of this, the datasheet is not really clear

TIME_WINDOW = 0xFF  //Not really sure the purpose of this, the datasheet is not really clear

All other registers are left at their default values. 

I am then reading the CLICK_SRC register in a loop. I am checking to see if bit 6 is a 1, which indicates that an interrupt has occurred.

Looking at the INT1 pin on the scope, it appears to be toggling. I understand that the INT1 will switch after CKICK_SRC is read, however the value read back indicates that no double (or single) click interrupt has occurred. Looking at the datasheet I also thought that all the other interrupts were disabled by default. 

If anyone has any suggestions or thoughts or even a working basic configuration, it would be much appreciated.

Thank you

Kind regards

Chithambaram 

10 REPLIES 10
Miroslav BATEK
ST Employee
Posted on January 05, 2017 at 10:37

Hi  Chithambaram,

double click recognition setup can be tricky.

For the parameters explanation please check chapter 8 in application note

http://www.st.com/resource/en/application_note/cd00290365.pdf

. It is for LIS3DH, but the single/double click settings will be basically the same.

Please be aware the time settings is linked with ODR settings.

Here is my working setup (ODR=50Hz), just for reference:

LIR_Click bit = 0:

0690X00000605x8QAA.png

LIR_Click bit = 1, Interrupt is cleared after CLICK_SRC read:

0690X00000605zAQAQ.png
Chithambaram Veerappan
Associate II
Posted on January 05, 2017 at 17:07

Hi Miroslav

Thank you for you tips. However I am still not having much success. 

To go back to basics, I am simply trying to get an interrupt on INT2 (I have a problem with INT1 on my PCB) when the acceleration in the y-axis exceeds a certain value. I am on the +/- 2g scale. When the INT2 threshold is set at 0x01 the thing seems to trigger when the PCB is on the bench. When set as anything else, even when the PCB is shocked, I do not get any response. Looking at the static data, the y-axis has a count range of between -14 to +10 - from the few tested I have undertaken.

Do you have any other suggestions?

Thank you

Chithambaram

Posted on January 05, 2017 at 18:21

I suppose you are not talking about double click configuration but about simple threshold interrupt now. I would need to know complete configuration of your sensor and also orientation of your sensor in consideration of gravity. I can check it, maybe I will see some problem. Please also double check all registers related to interrupt generator settings and linking interrupt generator to INT pins.

Here is an example of simple interrupt settings:

0690X00000605zmQAA.png0690X00000605vlQAA.png
Chithambaram Veerappan
Associate II
Posted on January 09, 2017 at 17:37

Hi Miroslav

Thank you for you tips. Sorry for the delay in responding.

I have used the configuration you suggested and am getting some success. This involves the INT2_SRC register indicating that an interrupt is active. However my problem is that I still cannot see the interrupt on the INT2 line. As previously noted I am not able to use the INT1 line on my current PCB due to a short. 

I have also tried reversing the polarity of the interrupt via the associated bit in CFG6.

Do the interrupt lines need to be pulled up to the Vdd? I have tried with and without pull-up and with both polarities with no success.

Based on the above, it looks like the interrupt is there, but is not being routed to the pin. The only thing that I have attached to the INT2 line is the pull up to Vdd and a scope. The pull-up (when used) is 100 kOhm. 

I have read that reading the INT2_SRC will clear the flag, so I have also tried keeping the microcontroller in an empty loop, but still I cannot see any interrupts on the scope. I have also tried enabling the latching of the interrupt (both with and without reading the INT2_SRC register).

This prototype board was built in-house, so there is potential for some damage to have occurred the part, however continuity checks between the pins seem to be as expected. New boards should be available soon, which may have better placement of the components. 

Any suggestions as to why the INT2_SRC register indicates an error but the same is not reflected on the pin.

Thank you

Kind regards

Chithambaram

Chithambaram Veerappan
Associate II
Posted on January 09, 2017 at 18:04

Yes, I am sending the value 0x20 to register 0x25 (CTRL_REG6).

I have disabled the other one by sending 0x00 to register 0x22 (CTRL_REG3).

Thanks

Chithambaram

Posted on January 09, 2017 at 18:00

What is your setting of CTRL_REG6 register?

There should be 0x20 to activate Interrupt generator 2 on INT2 pin.

0690X00000605kJQAQ.png

Please be aware that the device has two independent interrupt generators which can be linked to INT1 or INT2 pins. 

Posted on January 09, 2017 at 20:29

OK, Chithambaram.

Then I don't know where is the problem. If you see the interrupt is triggered (based on INT2_SRC value) and the interrupt generator is connected to INT2 (CTRL_REG6 = 0x20), you should see the signal on the pin.

To aswer your previous question, the interrupt pins have push-pull outputs, so pull-up is not needed.

What we can try, is to check your complete sensor setup. If you send me part of your code where you configure the sensor, I can try to replicate it and test it.

You can send it as private message, if you don't want to share it here.

Chithambaram Veerappan
Associate II
Posted on January 10, 2017 at 17:14

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6r6&d=%2Fa%2F0X0000000bwn%2F2IV_1ZlJfp0UPG9cItvzNtqKZLq9Z13lWNXw4oaB2mY&asPdf=false
Chithambaram Veerappan
Associate II
Posted on January 10, 2017 at 18:02

Hi Miroslav

Thank you for checking. I suspected that it now may be an issue with my board.

As noted, this is on a prototype board and my 'proper' boards are due to arrive soon. When they arrive, I will test an reply as to how it went.

Thanks

Chithambaram