Weird CubeIDE behavior when trying to use MEMS library
Hello!
This is what I have done yet:
- I started by launching STM32CubeMX and creating a new project for my specific STM32 Nucleo board.
- Once the project was created, I moved to the Pinout & Configuration tab. There, I enabled the I2C1 peripheral. I then set the SDA and SCL pins in accordance with the I2C configuration for my board.
- Next, I went to the "Software Packs Component Selector" and entered "lis3mdl" into the search bar. This allowed me to locate the lis3mdl component, and I opted for the I2C interface (over SPI) as this is how I plan to communicate with the sensor.
- Moving to the "Project Manager" tab, I changed the Toolchain / IDE to the one I am using (for example: KEIL or STM32CubeIDE). I also set the firmware package name and the project's location.
- In the "Advanced Settings" under "Code Generator", I chose "Copy all used library files into the project folder", to ensure all necessary files are available locally.
- After these configurations, I navigated to the "Middleware Configuration". Here, I clicked on the "X-CUBE-MEMS1", and then selected the "Board Part Mag" option which includes the LIS3MDL sensor.
- Within the "Middleware Configuration", I enabled the "LIS3MDL BUS IO driver - I2C" option. However, initially, under the "Found solutions" tab, it displayed "No solution".
- I ensured that the correct I2C bus was selected for the LIS3MDL BUS IO driver - I2C. After adjusting this, I was able to achieve "Found Solutions" for I2C1.
- Finally, I generated the project code.
Upon generating the code, I came across a problem where
MX_I2C1_Init();
was disappearing from the generated
main.c
file when I selected "I2C1" under "Middleware and Software Packs" in the "Found Solutions" tab. However, if I left it as "Undefined", the
MX_I2C1_Init();
would be included in the generated code. This issue is obstructing my progress with the sensor setup and I'm looking for help to troubleshoot and resolve this.


