Jump to content
I2Cdevlib Forums
Sign in to follow this  
rash

Issues while accessing magnetometer registers of MPU9150

Recommended Posts

Hi all, 

 

Problem: - Unable to access the magnetometer registers of MPU9150.

 

Output: -What I am getting is 0xFF on reading every register (corresponding to magnetometer). On the other hand I am able to access the registers of the accelerometer and the gyroscope perfectly. I have initialized the system with i2c master mode disabled and i2c bypass mode enabled. Following is the code I have used to initialize the system:-

single_byte_write(0x6B,0x01);

single_byte_write(0x19,0x01);

single_byte_write(0x1A,0x02);

single_byte_write(0x1B,0x11);

single_byte_write(0x1C,0x10);

single_byte_write(0x6A,0x00);

single_byte_write(0x37,0x02);

(‘single_byte_write(address,data) writes the data byte to the register with ‘address’ to the slave address as 0x69’)

 

I accessed the registers of accel. and gyro. as following:-

single_byte_read(0x75,wia_mpu); which returns 0x68 which is correct as the who_i_am register.
But when I tried to access the magnetometer registers as:-

single_byte_read_compass(0x00,wia_compass); it returns 0xFF while it should return 0x48.

 

In order to ensure that single_byte_read_compass()/single_byte_write_compass() works correctly I have used these functions with a change in slave address(from ‘0x0C’ to ‘0x69’)to access the registers of accel. and gyro. and it worked correctly.

 

(The difference between ‘single_byte_read()’ and ‘single_byte_read_compass()’ is just that the former uses the slave address as ‘0x69’ while the later uses ‘0x0C’ as the slave address. I have also tried ‘0x0D’, ‘0x0E’ and ‘0x0F’ as the slave address but the output remained the same.)

 

I have also ensured whether the MPU9150 is in pass-through mode. I have checked the output at the pins ‘ES_DA’ i.e. pin6 and the SDA i.e. pin24 with the help of oscilloscope which comes out to be exactly same, with by-pass mode enabled. With master-mode disabled and by-pass mode disabled the output at ‘ES_DA’ is zero always.

 

I have also tried the same procedure as above with not just one but many MPU9150s but the output remained the same, thus most likely there is some problem with the code.

 

Please help me figure it out.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×