cancel
Showing results for 
Search instead for 
Did you mean: 

tap detection doesn't work

DLich.1
Associate

Hello,

I am trying to use the LSM to detect taps . I use the default configuration which suggested in the application notes :

1. Write 60h to CTRL1_XL // Turn on the accelerometer 
                                              // ODR_XL = 417 Hz, FS_XL = ±2 g 
 
2. Write 0Eh to TAP_CFG0 // Enable tap detection on X, Y, Z-axis 
 
3. Write 0Ch to TAP_CFG1 // Set X-axis threshold and axes priority 
 
4. Write 8Ch to TAP_CFG2 // Set Y-axis threshold and enable interrupt 
 
5. Write 0Ch to TAP_THS_6D // Set Z-axis threshold 
 
6. Write 7Fh to INT_DUR2 // Set Duration, Quiet and Shock time windows 
 
7. Write 80h to WAKE_UP_THS // Single-tap and double-tap enabled (SINGLE_DOUBLE_TAP = 1) 
 
8. Write 08h to MD1_CFG // Double-tap interrupt driven to INT1 pin 

With this configuration i am able to get interrupts. My problem starts when i try to check the cause of the interrupt by reading TAP_SRC or ALL_INT_SRC.

When i read ALL_INT_SRC register i see that the cause of the interrupt was Wake-up event(WU_IA) which should be disabled as far as i understand from the configuration above( WAKE_UP_THS  = 0x80).

When i read TAP_SRC register i see that there was TAP event detection on one of the axis, but the bit's for SINGLE_TAP / DOUBLE_TAP / TAP_IA are all zero's. I would expect to get the SINGLE_TAP / DOUBLE_TAP bit's set.

Any suggestion on what may cause this not to work as expected ?

Thanks,

David.

1 ACCEPTED SOLUTION

Accepted Solutions
DLich.1
Associate

I found my problem. I configured the MCU to interrupt on the falling edge of the interrupt line instead of the rising edge. This caused the firmware to get the interrupt at the end of the TAP event so when i was reading the TAP_SRC register it wasn't valid any more.

View solution in original post

1 REPLY 1
DLich.1
Associate

I found my problem. I configured the MCU to interrupt on the falling edge of the interrupt line instead of the rising edge. This caused the firmware to get the interrupt at the end of the TAP event so when i was reading the TAP_SRC register it wasn't valid any more.