Skip to main content
Christopher1971
Associate II
October 18, 2023
Solved

LSM6DSOX INT1 & INT2 Trigger on Tap Detection

  • October 18, 2023
  • 3 replies
  • 3545 views

Hi,

I have designed a circuit with the LSM6SDOX.

It is operating via the I2C BUS and the Gyroscope and Accelerometer are sending data. I have also managed to configure Single and Double Tap detection, however it is the tap detection where I have an issue.

When I single tap, it works and triggers INT1 on the Microcontroller, when I double tap, it also works and triggers INT2, however the double tap also triggers the single tap at the same time.

The registers are configured as follows in the function below.

Please see a screen capture from my Oscilloscope attached. Yellow is the Single Tap, while Blue is the Double Tap. Hopefully it will be self explanatory.

Can anyone point me in the right direction on how I stop INT1 from triggering when INT2 is detected?

Thanks.

 

INT1 and INT2.PNG

/*-----------------------------------------------------------------*/

void configureRegisters() {
 
// Set FUNC_CFG_ACCESS and PIN_CTRL registers
writeRegister(LSM6DSOX_ADDRESS, FUNC_CFG_ACCESS, B00000000);
writeRegister(LSM6DSOX_ADDRESS, PIN_CTRL, B00000000);
 
// Configure INT1 and INT2 to trigger on tap events
writeRegister(LSM6DSOX_ADDRESS, INT1_CTRL, B00000000);
writeRegister(LSM6DSOX_ADDRESS, INT2_CTRL, B00000000);
 
// Configure tap detection registers
writeRegister(LSM6DSOX_ADDRESS, TAP_CFG0, B00001110);
writeRegister(LSM6DSOX_ADDRESS, TAP_CFG1, B00001111);
writeRegister(LSM6DSOX_ADDRESS, TAP_CFG2, B10001000);
writeRegister(LSM6DSOX_ADDRESS, TAP_THS_6D, B00001000);
writeRegister(LSM6DSOX_ADDRESS, TAP_SRC, B00110000);
 
writeRegister(LSM6DSOX_ADDRESS, INT_DUR2, B00111111);
writeRegister(LSM6DSOX_ADDRESS, WAKE_UP_THS, B10000000);
writeRegister(LSM6DSOX_ADDRESS, MD1_CFG, B01000000);
writeRegister(LSM6DSOX_ADDRESS, MD2_CFG, B00001000);
 
// Additional configurations for the LSM6DSOX:
writeRegister(LSM6DSOX_ADDRESS, CTRL1_XL, B01011100);
writeRegister(LSM6DSOX_ADDRESS, CTRL2_G, B01011100);
writeRegister(LSM6DSOX_ADDRESS, CTRL3_C, B00000100);
writeRegister(LSM6DSOX_ADDRESS, CTRL4_C, B00000000);
writeRegister(LSM6DSOX_ADDRESS, CTRL5_C, B00000000);
writeRegister(LSM6DSOX_ADDRESS, CTRL6_C, B00000000);
writeRegister(LSM6DSOX_ADDRESS, CTRL7_G, B00000000);
writeRegister(LSM6DSOX_ADDRESS, CTRL8_XL, B00000000);
writeRegister(LSM6DSOX_ADDRESS, CTRL9_XL, B11100000);
writeRegister(LSM6DSOX_ADDRESS, CTRL10_C, B00000000);
}
This topic has been closed for replies.
Best answer by Federica Bossi

Hi @Christopher1971 ,

Welcome to ST Community!

The single tap interrupt is triggered by the first tap of the double tap, so it has to be there.

What I can suggest is to check for both interrupts in the INT1 routine and continue doing what you have to do for the single tap only if just the INT1 is triggered.

 

To better explain, here is the pseudo code:

int1_callback(){

  int1_up = 1;

}

 

int2_callback(){

  int2_up = 1;

}

 

main(){

  while(1){

    if((int1_up==1) && (int2_up==0)){

      /// int1 routine

    }

    if(int2up==1){

      /// int2 routine

    }

  }

}

If this helps you, please mark my answer as "Best Answer" by clicking on the "Accept as Solution" button, this can be helpful for Community users to find this solution faster :)

3 replies

Federica Bossi
Federica BossiBest answer
Technical Moderator
October 19, 2023

Hi @Christopher1971 ,

Welcome to ST Community!

The single tap interrupt is triggered by the first tap of the double tap, so it has to be there.

What I can suggest is to check for both interrupts in the INT1 routine and continue doing what you have to do for the single tap only if just the INT1 is triggered.

 

To better explain, here is the pseudo code:

int1_callback(){

  int1_up = 1;

}

 

int2_callback(){

  int2_up = 1;

}

 

main(){

  while(1){

    if((int1_up==1) && (int2_up==0)){

      /// int1 routine

    }

    if(int2up==1){

      /// int2 routine

    }

  }

}

If this helps you, please mark my answer as "Best Answer" by clicking on the "Accept as Solution" button, this can be helpful for Community users to find this solution faster :)

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Christopher1971
Associate II
October 19, 2023

Hi Federica,

Thanks for replying. 

I'm very pleased as this means I understood the registers after all!

It is the best answer!

Regards,

Christopher

Associate II
October 25, 2023

Hi Christopher1971. I'm trying to enable double tap on lsm6dsox. If your code works correctly, can you share it with me?

 

Explorer
January 11, 2024

thank you for your input and your test code.
- just one remark:

Application note AN5272 states:
"Single and double-tap recognition work independently of the selected output data rate. Recommended minimum accelerometer ODR for these functions is 417 Hz."

Your code seems to use only 104Hz

 

best regards

ajanky

Christopher1971
Associate II
January 13, 2024

Hi Ajanky,

I have looked at my code and I haven't defined the FIFO_CTRL3 (09h) register you refer to.

Therefore, as I am not setting any values in this register, it uses the default register values on power up.

Looking at the datasheet, it states that "Gyro not batched in FIFO (default)", so these settings do not apply.

I haven't read AN5272 as my code is working as well as the circuit/PCB for my purposes.

Regards,

Christopher