cancel
Showing results for 
Search instead for 
Did you mean: 

I2C management STM32F407 + LSM6DSV16XTR + LIS2MDLTR

MRaff.1
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
MRaff.1
Associate III

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. 

View solution in original post

3 REPLIES 3
MRaff.1
Associate III

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. 


@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.