cancel
Showing results for 
Search instead for 
Did you mean: 

Weird CubeIDE behavior when trying to use MEMS library

DLid.1
Associate II

Hello!

This is what I have done yet:

  1. I started by launching STM32CubeMX and creating a new project for my specific STM32 Nucleo board.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. Within the "Middleware Configuration", I enabled the "LIS3MDL BUS IO driver - I2C" option. However, initially, under the "Found solutions" tab, it displayed "No solution".
  8. 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.
  9. 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.


_legacyfs_online_stmicro_images_0693W00000bl0QzQAI.png 


_legacyfs_online_stmicro_images_0693W00000bl0RJQAY.png

1 ACCEPTED SOLUTION

Accepted Solutions
Foued_KH
ST Employee

Hello @DLid.1​ ,

when you use the CMSIS pack of the MEMS, You can find the Initialization of the MX_I2C1_init(); in the custom_bus.c file not in the main.c.


_legacyfs_online_stmicro_images_0693W00000bl3yGQAQ.png 

But if you

Foued

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.

View solution in original post

1 REPLY 1
Foued_KH
ST Employee

Hello @DLid.1​ ,

when you use the CMSIS pack of the MEMS, You can find the Initialization of the MX_I2C1_init(); in the custom_bus.c file not in the main.c.


_legacyfs_online_stmicro_images_0693W00000bl3yGQAQ.png 

But if you

Foued

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.