2024-10-30 03:30 AM
Hello,
I having an issue with the LSM6DSL. It's doesn't trigger interruptions on INT1 or INT2.
I'm working with the STM32WB10CC and I'm connected through SPI to the LSM6DSL. The SPI is working I'm able to communicate with the sensor but it's not triggering interruptions.
Here is what i have already tried :
I can't figure out what is going on.
Here is my setup :
SPI setup :
/**
* Function to set LSM6DS SPI communication
*/
static void LSM6DS_setup_SPI()
{
/**
* Set SPI communication settings
*/
lsm6ds_ctx.spi_periph.spi_handle.Instance = SPI1;
lsm6ds_ctx.spi_periph.spi_handle.Init.Mode = SPI_MODE_MASTER;
lsm6ds_ctx.spi_periph.spi_handle.Init.Direction = SPI_DIRECTION_2LINES;
lsm6ds_ctx.spi_periph.spi_handle.Init.DataSize = SPI_DATASIZE_8BIT;
lsm6ds_ctx.spi_periph.spi_handle.Init.CLKPolarity = SPI_POLARITY_LOW;
lsm6ds_ctx.spi_periph.spi_handle.Init.CLKPhase = SPI_PHASE_1EDGE;
lsm6ds_ctx.spi_periph.spi_handle.Init.NSS = SPI_NSS_HARD_OUTPUT;
lsm6ds_ctx.spi_periph.spi_handle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
lsm6ds_ctx.spi_periph.spi_handle.Init.FirstBit = SPI_FIRSTBIT_MSB;
lsm6ds_ctx.spi_periph.spi_handle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
}
Interruption pins setup :
GPIO_InitTypeDef GPIO_InitStruct = {0};
/**
* Initialization of interruption pin for LSM6DSL
*/
GPIO_InitStruct.Pin = LSM6DSL_INT1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(LSM6DSL_INT1_GPIO_Port, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LSM6DSL_INT2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(LSM6DSL_INT2_GPIO_Port, &GPIO_InitStruct);
/**
* Set callback function for pins interruption
*/
gpio_set_callback(LSM6DSL_INT1_Pin, LSM6DS_int1_irq_cb);
gpio_set_callback(LSM6DSL_INT2_Pin, LSM6DS_int2_irq_cb);
/**
* Set priority and enable interruption
*/
// Enable interruption line for INT1 and INT2
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
LSM6DSL setup :
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_CTRL1_XL, 0x4D); // Acc at 104Hz, +/-8g, LFP1 bandwidth at 208Hz/2
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_CTRL8_XL, 0x00); // LFP2 not selected in CTRL8_XL
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_CTRL6_C, 0x00); // Acc in high-perf mode
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_CTRL2_G, 0x44); // Gyro at 104Hz, 500dps (LFP1 not selected in CTRL4_C)
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_CTRL7_G, 0x00); // Gyro in high-perf mode, high-pass filter not enabled
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_INT1_CTRL, 0x01); // Acc data-ready enable on INT1 (bits are differents in the register)
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_INT2_CTRL, 0x00); // Disable data interruption on INT2
// Wake up on movement
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_TAP_CFG, 0x81); // Disable double tap and enable basic interrupts,
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_WAKE_UP_DUR, 0x00); // no duration
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_WAKE_UP_THS, 0x02); // Set wake-up threshold
// Free fall
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_FREE_FALL, 0x33); // Set Free fall threshold & duration event
Wake-up on movement setup on INT2 :
//Wake up on movement
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_CTRL1_XL, 0x45); // Acc at 104Hz (normal mode), +/-16g, LFP1 bandwidth at 208Hz/2
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_CTRL6_C, 0x10); // Acc not in high-perf
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_INT1_CTRL, 0x00); // INT1 disable
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_CTRL2_G, 0x00); // Gyro power down
spi_write8(lsm6ds_ctx.spi_periph, LSM6DSL_MD2_CFG, 0x34); // INT2 pour 6d only & wakeup & free fall
Solved! Go to Solution.
2024-11-04 01:15 AM
Hi Federica,
I solved my problem. I was having an issue with the CS pin on my SPI bus. I was able to communicate with the sensor, but only for a single request; all subsequent requests to configure the LSM6DSL did nothing and didn’t return an error. Looking at the ST examples helped me, so thank you.
2024-10-31 06:58 AM
2024-11-04 01:15 AM
Hi Federica,
I solved my problem. I was having an issue with the CS pin on my SPI bus. I was able to communicate with the sensor, but only for a single request; all subsequent requests to configure the LSM6DSL did nothing and didn’t return an error. Looking at the ST examples helped me, so thank you.