I am working on a project using the SensiBLE module. It includes an STM32L476RG microcontroller and an LSM6DS3 IMU sensor. I am using I2C for communication between the two.
I am trying to enable the accelerometer data-ready interrupt on INT1 using the following setup:
CTRL1XL ODR = 104Hz, FS = 2G
CTRL3_C BDU = 1, IF_INC = 1
CTRL4_C INT2_on_INT1 = 1 and SLEEP_G=1
CTRL6_C XL_HM_MODE = 1
MASTER_CONFIG DRDY_ON_INT1 = 1
INT1CTRL DRDY_XL = 1
However, the interrupt does not seem to trigger. To confirm that I would use an oscilloscope, however, the SensiBLE module is compact and I can't probe the MCU pins. However, as a test, if I replace the EXTI pin from the IMU INT1 pin with the SensiBLE button EXTI input pin and leave the I2C functions to retrieve accelerometer data from the IMU in the callback and cplt functions, it works successfully.
What is missing in the IMU configuration to fully enable the data-ready interrupt? Should I do it on INT2?
I also tried different configurations with:
MASTER_CFG DRDY_ON_INT1 = 0
MD1CFG INT1_TIMER = 0 and then 1
ACC ODR = 416Hz and then 12.5Hz
However, the issue still occurs in all the various configurations used.
Just to test that the GPIO_EXTI pin configuration is correct, I configured the LSM6DS3 to trigger an interrupt on a single tap (following the example on AN4650 section 4.5.4) and it works successfully. Hence, there is something I misconfigured in the Data-Ready interrupt configuration.
Well, I found something interesting!
When I program my firmware into the STM32 chip (regardless if I use STM32CubeIDE or STM32CubeProg to program it) or when I do a HW reset the SensiBLE via the reset button on the SensiEDGE Development Board, the firmware crashes. If, instead, I power-cycle the device, the code works.
Another thing I noticed, the debugger does not work properly anymore. I can get it to start however when it runs MX_GPIO_Init() in the main.cc file the debugger loses connection with the device and stops debugging.
My theory is that the interrupt I am trying to enable is automatically triggered by the IMU sensor and if there is any timing issue it errors out. On the other side, if enable any other interrupt that triggers manually or by a movement, the code gets programmed and run correctly.
Where should I be looking to fix this issue?
I have looked at
and added a delay before (or even after) SystemClock_Config() but it didn't help.