Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing MPU9250's magnetometer via SPI #367

Open
Qammar-25 opened this issue May 10, 2019 · 14 comments
Open

Accessing MPU9250's magnetometer via SPI #367

Qammar-25 opened this issue May 10, 2019 · 14 comments

Comments

@Qammar-25
Copy link

Qammar-25 commented May 10, 2019

Hi Kriswiner,

I am using MPU9250 to get accelerometer and gyroscope readings via SPI. However, i am unable to sort out how can i access the magnetometer through SPI? Any help regarding the issue will be appreciated.

@kriswiner
Copy link
Owner

kriswiner commented May 10, 2019 via email

@Qammar-25
Copy link
Author

Thank you Kris. I successfully read the Who Am I register by making AK8963 as an I2C slave (SLAVE 4) of MPU9250. However, now i want to read magnetometer values for which i want to configure my CNTL1 register for continuous measurement mode 2. I am trying to write to this register but when i read it back it shows 0x00. Why i cannot write to this register?

@kriswiner
Copy link
Owner

kriswiner commented May 13, 2019 via email

@Qammar-25
Copy link
Author

Yes

@kriswiner
Copy link
Owner

kriswiner commented May 14, 2019 via email

@Qammar-25
Copy link
Author

The datasheet says it is a read-only register.

@kriswiner
Copy link
Owner

kriswiner commented May 14, 2019 via email

@Qammar-25
Copy link
Author

How can i set the continuous measurement mode?

@kriswiner
Copy link
Owner

kriswiner commented May 14, 2019 via email

@kriswiner
Copy link
Owner

kriswiner commented May 14, 2019 via email

@Qammar-25
Copy link
Author

Thank you for your help Kris. I have resolved the issue which was in the sequence of sending commands. The DO register of slave 4 should have been written first before enabling the slave. I was doing the other way around.

@Qammar-25
Copy link
Author

I can read and write to registers now. However, when i enter fuse mode to access Axial Sensitivity Adjustment Values, all three registers return me zero. Are these values correct?

@kriswiner
Copy link
Owner

kriswiner commented May 21, 2019 via email

@PJiaHeng
Copy link

Hello, kriswiner. I have an issue of MPU9250 magnetometer.
I use your example code as follow: https://github.com/kriswiner/MPU9250/tree/master/AK8963_as_slave.

MPU9250 is working smoothly at the beginning(Interface: SPI). But a few moment later, the magnetometer data doesn’t change anymore.It needs to cut down the power of MPU9250 to fix it.
The values of register(I2C_MST_STATUS) and register(INT_STATUS) are 0x01 and 0x09 respectively, it means salve0 receives a nack signal(I use slave0 access to magnetometer). In my view, the communication between MPU9250 and AK8963 is break. So, I deduce that AK8963 has been shutdown. But I can’t understand why the magnetometer has this problem and have no idea that how to fix it.

I’ve been nagged with this issue for weeks. Can you give me any advice?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants