cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DW12 – Single Tap Interrupt Not Triggering on STM32L496 (PE7 GPIO)

Mounika_Navtech
Visitor

Hello,

I’m working with the LIS2DW12 vibration sensor for single-tap detection. I have configured the sensor registers according to the application note for enabling single tap.

When I continuously read the TAP_SRC register in polling mode, I’m able to detect single taps successfully.

However, I want to use interrupts instead of polling. I have connected the LIS2DW12’s INT1 pin to the PE7 GPIO pin of my STM32L496 controller. Despite this, I am not receiving any interrupt signal on PE7 when I tap the sensor. please check the single tap init function :

void LIS2DW12_Init_Single_TAP(void) {

 

message[0] = 0x74;

if(HAL_I2C_Mem_Write(&hi2c3, LIS2DW12_Adrr, CTRL1, 1, message, 1, 1000)==HAL_OK)

{

message[0] = 0x0C;

if(HAL_I2C_Mem_Write(&hi2c3, LIS2DW12_Adrr, CTRL6, 1, message, 1, 1000)==HAL_OK)

{

 

message[0] = 0x09;

if(HAL_I2C_Mem_Write(&hi2c3, LIS2DW12_Adrr, TAP_THS_X, 1, message, 1, 1000)==HAL_OK)

{

message[0] = 0xE9;

if(HAL_I2C_Mem_Write(&hi2c3, LIS2DW12_Adrr, TAP_THS_Y, 1, message, 1, 1000)==HAL_OK)

{

message[0] = 0xE9;

if(HAL_I2C_Mem_Write(&hi2c3, LIS2DW12_Adrr, TAP_THS_Z, 1, message, 1, 1000)==HAL_OK)

{

message[0] = 0x06;

if(HAL_I2C_Mem_Write(&hi2c3, LIS2DW12_Adrr, INT_DUR, 1, message, 1, 1000)==HAL_OK)

{

message[0] = 0x00;

if(HAL_I2C_Mem_Write(&hi2c3, LIS2DW12_Adrr, WAKE_UP_THS, 1, message, 1, 1000)==HAL_OK)

{

message[0] = 0x40;

if(HAL_I2C_Mem_Write(&hi2c3, LIS2DW12_Adrr, CTRL4_INT1_PAD_CTRL, 1, message, 1,1000)==HAL_OK)

{

message[0] = 0x00;

if(HAL_I2C_Mem_Write(&hi2c3, LIS2DW12_Adrr, CTRL3, 1, message, 1, 1000)==HAL_OK)

{

HAL_Delay(10);

message[0] = 0x22;

if(HAL_I2C_Mem_Write(&hi2c3, LIS2DW12_Adrr, CTRL7, 1, message, 1, 1000)==HAL_OK)

{

printf("\r\n single tap init completed!\r\n");

}

}

}

}

}

}

}

}

}

}

}

 

this is the gpio callback for interrupt:

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){

HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10, GPIO_PIN_SET); // HeartBeatLed

 

if (GPIO_Pin == GPIO_PIN_7) {

uint8_t tap_src=0;

HAL_I2C_Mem_Read(&hi2c3, LIS2DW12_Adrr, 0x39, 1, &tap_src, 1, 1000); // Read TAP_SRC

 

if (tap_src & 0x40) { // TAP_IA bit

tap_detected = 1;

// HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10, GPIO_PIN_SET); // HeartBeatLed

}

}

 

}

 IRQ handler:

void EXTI9_5_IRQHandler(void)

{

/* USER CODE BEGIN EXTI9_5_IRQn 0 */

/* USER CODE END EXTI9_5_IRQn 0 */

HAL_GPIO_EXTI_IRQHandler(INT1_IMU_Pin);

/* USER CODE BEGIN EXTI9_5_IRQn 1 */

 

/* USER CODE END EXTI9_5_IRQn 1 */

}

Could you please help me with:

  1. Sensor Configuration: Are there any additional registers I should configure to properly route the single-tap interrupt to INT1?

  2. STM32 GPIO Setup: Are there any specific settings needed on PE7 (e.g. interrupt mode, pull-up/pull-down, EXTI configuration) to detect the interrupt?

  3. Troubleshooting Tips: How can I confirm whether the sensor is actually toggling the INT1 pin during a tap event?

Thanks in advance for your support!

0 REPLIES 0