cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] LIS3DH on I2C: setting Activity Interrupt

Eric Tsai
Associate
Posted on June 09, 2018 at 11:44

[EDIT] Solved!  I missed where the app note mentioned that I have to set REG3's <I1_IA1> bit.  Once that's done, I get interrupts on motion.

'App Note AN3308'

Hello,

I'm trying to enable interrupt on a LIS3DH using mBED, on a nRF51822.  Here's the program for reference:

Main:  

https://os.mbed.com/users/electronichamsters/code/AA_LIS3DH_I2C/file/3eaae3de806e/main.cpp/

 

LIS3DH.cpp:  

https://os.mbed.com/users/electronichamsters/code/LIS3DH/file/c32d2b25d4c2/LIS3DH.cpp/

 

I'm trying to set the INT1 interrupt on movement, but it doesn't seem to be working.  I'm reading the acceleration data OK.  But when I shake the sensor, it's not waking up my microcontroller.  For comparison, I used someone else's code for an SPI implementation of the LIS3DH library, and using the EXACT same hardware, I'm able to set INT1 for movement interrupt and it wakes up my microcontroller.  But I need to use I2C because of other peripherals that I want to add.

Knowing that the hardware and wiring is OK, and knowing that the I2C code works as far as getting acceleration data, I've narrowed it down to the differences between how the I2C and SPI version is setting the INT1_CFG.

For reference, here's the SPI version that works for setting activity interrupt:

SPI version:  

https://os.mbed.com/users/electronichamsters/code/AA_LIS3DH_SPI/file/46ad303d911c/main.cpp/

 

I'm setting this configuration in the I2C version:

INT1_CFG (0x30):  01111111;   //movement recognition, on all 3 axis.  I've also tried 00111111 (or combination of events)

INT1_THS (0x32):  00000010;  //threshold.  I've tried 0x01 too.

I'm doing a read of INT1_SRC to clear any interrupts.  I'm shaking the sensor to try to activate the interrupt.  Not getting anything with the I2C, but the SPI interrupts very reliably.

I've also try setting some values in INT1_DURATION, but no difference.

Am I missing anything else?

0 REPLIES 0