needs help for MPU 9250

No sure if anyone has been working with this thing yet.
the twi.h need to be changed to 400khz, and i did the same setup for the device as the 9150 because the reg map are almost exactly the same.

the problem are from the magnetometer onchip.
first of all, i need to bypass the mpu6500, i want to read all data, but so far, i tried to just do reads, but it didn't work and the program stops. so i need to disable bypass to read mpu6500 and enable it to read magnetometer. and it kind of works. but i don't think its the right way to do it.

second, the magnetometer should has a continuous mode according to the datasheet. but it does not work, on the old 9150 we need to do
mpu9250.writeBits(0x0C, 0x0A, 3,0,1); //single read
every time before we read. and now there's finally a continuous read but it doesn't seems to work.
when i do mpu9250.writeBits(0x0C, 0x0A, 3,0,2); //continuous mode 1
the data stays the same, and i have to call it everytime i want to get new data.

anyone can help me out here?

what do you mean by "bypass" here ?

michinyon:
what do you mean by "bypass" here ?

the MPU9250 has two chips on it. to access to the magnetometer, we need to go through the gyro+accel to read it. and the register 55 on the MPU 6500 has a BYPASS_EN. only when that is activated, user can access the magnetometer. but the problem im having is, once i enable that and another register to get to the magnetometer. i can't read the mpu6500 anymore.

I have not got my 9250 module yet.

I use the 6050 with an external magetometer on a separate PCB, connected to the secondary I2C bus. It was a bit of a nightmare to get it to work. The arrangement looks very similar to the diagram on page 21 of the 9250 datasheet, except that the magnet device is now in the chip package. Also I was using the HMC5883L not the ak-whatever japanese one.

IIRC, there are at least two ways that this can potentially work.

One way, is to use the main I2C bus to look right through the 9250 and communicate with the magnetometer directly. I could never get this to work. I guess this scheme is the "serial interface bypass".

The other way, is to tell the 9250 to continually read the 6 data registers of the magnetic device itself, and copy the data into 6 of the spare registers on the 9250, and then you just read the data from those 6 spare registers on the 9250. It was a problem to get this to work, but once I got it working, it worked just fine. I guess this scheme is not the "serial interface bypass".

It seems exceedingly strange, that the datasheet for this device still contains all the explanation of how to connect an external device such as a magnetometer to it, but contains no information at all about how to access the on-chip magnetometer. It's a complete mystery. Unless there is an explanation somewhere other than the datasheet and register map document.

Does the device show up with 2 I2C addresses ?

i can see the mpu6500's address, but i can't see the magnetometer's address. this product's datasheet is very confusing. the 9150's datasheet is more complete.

Did anyone get the magnetometer to work in bypass mode?

I set the bypass enable bit in the MPU9250 and simply try to read the magnetometer device ID register. The part does not respond giving me a NAK on the I2C bus (per the scope and the software) at address 0x0C. I also tried every other I2C address and it responded to none except the MPU9250 address. I've scoured the data sheets for a clue and also reviewed the software I can find online and cannot figure out why it won't respond (unless my device is bad...) I'm running the part at a 100 KHz I2C clock rate.

michinyon:
The other way, is to tell the 9250 to continually read the 6 data registers of the magnetic device itself, and copy the data into 6 of the spare registers on the 9250, and then you just read the data from those 6 spare registers on the 9250. It was a problem to get this to work, but once I got it working, it worked just fine. I guess this scheme is not the "serial interface bypass".

I am still dealing with this issue. I am trying what you suggested and still getting do response from it. You mentioned you had issues with getting this working . Would you mind posting the code you used to set this up? I would really appreciate it.

// A function to configure the HMC device on the auxilliary I2C bus
// The only function required to set up the magnetometer is to configure
// continuous mode.
// I2C address is HMC5883L_Address
// Set HMC_ModeRegister to value HMC_Measurement_Continuous
//
void initMag()
{
   mpu.setSlaveAddress( 0, 0x7f & HMC5883L_Address );    // clear the msbit for a write operation
   mpu.setSlaveRegister( 0, HMC_ModeRegister );
   mpu.setSlaveEnabled( 0, true );  
   mpu.setSlaveWriteMode( 0, false );
   mpu.setSlaveDataLength( 0, 1 );
   mpu.setSlaveOutputByte( 0, HMC_Measurement_Continuous );
   
   delay(10) ;
   mpu.setSlaveRegister( 0, HMC_ConfigurationRegisterB );
   mpu.setSlaveEnabled( 0, true );  
   mpu.setSlaveWriteMode( 0, false );
   mpu.setSlaveDataLength( 0, 1 );
   mpu.setSlaveOutputByte( 0, 0x20 );
   delay(10) ;   
   
}
// A function to initiate continuous reading of the magnetometer device
void runMag()
{
   mpu.setSlaveAddress( 0, 0x80 | HMC5883L_Address );    // set the msbit for a read operation
   mpu.setSlaveRegister( 0, HMC_DataRegisterBegin );
   //mpu.setSlaveRegister( 0, 0x00 );
   
   mpu.setSlaveWriteMode( 0, false ) ;    //  if false, writes the register address before reading OR writing data
   mpu.setSlaveDataLength( 0, 6 ) ;
   mpu.setSlave4MasterDelay( 31 );          // reduces sample rate by 1/(1+31)    Note 31 is the biggest number allowed here
   mpu.setSlaveDelayEnabled( 0, true );
}

void getMag( int* buf )
{
  buf[0]=mpu.getExternalSensorWord(0) ;  // gets byte 0 and 1 from the sensor buffer and makes byte 0 the most significant byte of the word
  buf[1]=mpu.getExternalSensorWord(2) ;   
  buf[2]=mpu.getExternalSensorWord(4) ;
  //buf[3]=mpu.getExternalSensorWord(6) ;
  //buf[4]=mpu.getExternalSensorWord(8) ;
}

I found these two lines of code in the setup( ) which it probably needs. The "mpu" here is a class object for the MPU6050 device which is based on Rowberg's with some modifications. I also use a different I2C implementation but I don't think that is relevant here.

     mpu.setMasterClockSpeed( (uint8_t) 13 );   //  set auxilliary I2C clock rate to 400 kHz.    
    mpu.setI2CMasterModeEnabled( true );       //  turns on the secondary I2C