Skip to main content
Graduate II
July 4, 2018
Question

LIS3DH interrupts again

  • July 4, 2018
  • 3 replies
  • 1267 views
Posted on July 04, 2018 at 12:06

I intend to use the LIS3DH as a very low power activity detector but have had no success in getting its interrupt output to behave in my application: I can make it stay always on or always off but never does it react to motion.

To retain my sanity, I have gone back to the application note and written code which does exactly what the application note (section 6.3.3) says but I can't make that work either: I can see the X/Y/Z values changing but the IA bit in INT1_SRC is never set, no matter how violently I shake the chip (which is on an STEVAL-MKI105V1 board attached via I2C).  What am I doing wrong? Help!

My code (in mbed-os, running on an STM32F437VG) is attached to this post, its output is below:

Read I_AM_LIS3DH (0x0f): 0x33.

Write CTRL_REG1 (0x20): 0x57.

Write CTRL_REG2 (0x21): 0x09.

Write CTRL_REG3 (0x22): 0x40.

Write CTRL_REG4 (0x23): 0x00.

Write CTRL_REG5 (0x24): 0x08.

Write INT1_THS (0x32): 0x10.

Write INT1_DURATION (0x33): 0x00.

Read REFERENCE (0x26): 0x00.

Write INT1_CFG (0x34): 0x2a.

Read INT1_SRC (0x31): 0x00.

Read X 64 Y 64 Z 65472.

Read INT1_SRC (0x31): 0x00.

Read X 65472 Y 65472 Z 0.

Read INT1_SRC (0x31): 0x00.

Read X 64 Y 0 Z 65472.

Read INT1_SRC (0x31): 0x00.

Read X 0 Y 65472 Z 0.

Read INT1_SRC (0x31): 0x00.

Read X 0 Y 0 Z 65472.

Read INT1_SRC (0x31): 0x00.

Read X 0 Y 64 Z 65472.

Read INT1_SRC (0x31): 0x00.

Read X 0 Y 65408 Z 0.

Read INT1_SRC (0x31): 0x00.

Read X 65472 Y 0 Z 0.

Read INT1_SRC (0x31): 0x00.

Read X 65408 Y 0 Z 65472.

Read INT1_SRC (0x31): 0x00.

...

Read X 0 Y 64960 Z 1088.

Read INT1_SRC (0x31): 0x00.

Read X 1088 Y 2496 Z 65088.

Read INT1_SRC (0x31): 0x00.

Read X 1216 Y 64832 Z 63808.

Read INT1_SRC (0x31): 0x00.

Read X 1408 Y 1280 Z 63424.

Read INT1_SRC (0x31): 0x00.

Read X 1792 Y 4608 Z 63168.

Read INT1_SRC (0x31): 0x00.

Read X 65472 Y 0 Z 64320.

Read INT1_SRC (0x31): 0x00.

Read X 256 Y 768 Z 1600.

Read INT1_SRC (0x31): 0x00.

Read X 1792 Y 3520 Z 2688.

Read INT1_SRC (0x31): 0x00.

Read X 128 Y 1216 Z 64576.

Read INT1_SRC (0x31): 0x00.

...

Rob

#lis3dh
    This topic has been closed for replies.

    3 replies

    ST Employee
    July 4, 2018
    Posted on July 04, 2018 at 17:53

    Your sensor configuration is OK, I have tested it and the interrupt is triggered.

    Can you check the INT pin with scope or logic analyzer?

    Graduate II
    July 4, 2018
    Posted on July 04, 2018 at 18:07

    Ooo, hi, thanks very much for doing that.  I have a logic analyzer connected to INT1 waiting for a rising edge but it never sees one, INT1 is always low.  And of course INT_SRC always returns zero.  Did you really see an interrupt being generated with my sample code?  How hard did you have to shove the device to make the interrupt occur?

    ST Employee
    July 4, 2018
    Posted on July 04, 2018 at 18:14

    I did not test your sample code, I'm not much familiar with mbed, but I used exactly your sensor configuration, and it is OK.

    Gentle movement was needed to trigger the interrupt.

    Maybe you can try to read back all the configuration.

    Graduate II
    July 6, 2018
    Posted on July 06, 2018 at 10:15

    Sorted it!  Checking and double-checking, in my simple code I was writing to INT2_CFG (0x34) not INT1_CFG (0x30).  Write to the correct register and it works.  Of course, this mistake is only in my sample code posted here, my real target code is writing to the correct register, but at least I have an example to work from now.

    Thanks for all your help

    Batek.Miroslav

    !

    Rob

    Graduate II
    July 6, 2018
    Posted on July 06, 2018 at 12:26

    In case it helps anyone else, I've now got to the bottom of the problem in my real target code.  It was down to understanding the meaning of the 6 interrupt enable bits in INTx_CFG.  I had thought that if I set a threshold of, say 16, then if I set, for instance, the ZHIE and ZLIE bits 

    in INTx_CFG

    , then I would get an interrupt if the Z axis acceleration went above +16 or below -16.  What I now understand it that it will give me an interrupt if the Z axis acceleration goes above 16 or below 16, hence it goes off all the time.  So the resolution is to set just the xHIE bits, which is what the example code does.