Skip to main content
MRaff.1
Associate III
August 20, 2024
Solved

I2C management STM32F407 + LSM6DSV16XTR + LIS2MDLTR

  • August 20, 2024
  • 1 reply
  • 1304 views

Hello, 

    I have a custom board with STM32F407 CPU,  LSM6DSV16XTR accelerometer+gyroscope and LIS2MDLTR magnetometer.

I aim to get board inclination and the position of the north using the magnetometer for a telescope. 

Using CubeMX, I have enabled the LSM6DSV16B and the LIS2MDLTR in the Middleware package.

 

When generating, CubeMX removes the I2C1 initialization from main. But I need the I2C1 peripheral for other devices in the board, not only for MEMS. What is the correct way to manage this?

 

Thank you.

Best answer by MRaff.1

OK, fixed by adding the following lines in the provided USE_CODE areas in main.c:

 

extern I2C_HandleTypeDef hi2c1;

BSP_I2C1_Init();

 

Now it is not completely clear to me how to get the most accurate inclination an eCompass information since there are a lot of possibilities. Is the MotionFx the definitive solution or it is better to use MotionTL and MotionEc or maybe a combination of these?

 

Thank you. 

1 reply

MRaff.1
MRaff.1AuthorBest answer
Associate III
August 21, 2024

OK, fixed by adding the following lines in the provided USE_CODE areas in main.c:

 

extern I2C_HandleTypeDef hi2c1;

BSP_I2C1_Init();

 

Now it is not completely clear to me how to get the most accurate inclination an eCompass information since there are a lot of possibilities. Is the MotionFx the definitive solution or it is better to use MotionTL and MotionEc or maybe a combination of these?

 

Thank you. 

Andrew Neil
Super User
August 21, 2024

@MRaff.1 wrote:

OK, fixed by adding the following lines in the provided USE_CODE areas in main.c. 


Good - please mark that as the solution: 

https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256

 


@MRaff.1 wrote:

Now it is not completely clear to me how to get the most accurate inclination an eCompass information since there are a lot of possibilities. Is the MotionFx the definitive solution or it is better to use MotionTL and MotionEc or maybe a combination of these?. 


I think that's a new question - so better in a new thread.

Please give a link here so people can find it.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
MRaff.1
MRaff.1Author
Associate III
August 21, 2024