This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Standalone code for MPU9250, facing issues with I2Ctransfer.

Other Parts Discussed in Thread: CC2650

Hi,

     I am trying to write standalone code for MPU9250 in CC2650 .

When i try to do i2ctransfer for WHO_AM_I for Mpu9250 , i see error. I am not able to make out what is reason for this.

Also saw in wiki, that :

  • Write 01:68 to Register Device ID (this selects I2C bus 1 and Movement sensor)

                          How do i do this, as i am feeling I2C bus that i selected is on bus 0.

Can you please glance through my code and let me know whats wrong here.

--------------------------------------------------------------------------------------------------------------------

I2C_init();
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_400kHz;
i2cParams.transferMode =I2C_MODE_BLOCKING;
i2c = I2C_open(Board_I2C, &i2cParams);
if (i2c == NULL) {
System_abort("Error Initializing I2C\n");
}
else {
System_printf("I2C Initialized!\n");
}

Task_sleep(1000000 / Clock_tickPeriod);
System_flush();

//Read MPU9250 device ID
txBuffer[0] = WHO_AM_I;
i2cTransaction.slaveAddress = Board_MPU9250_ADDR;//MPU9250 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 1;

if(PIN_getOutputValue(Board_MPU_POWER) == Board_MPU_POWER_ON)
System_printf("MPU9250 powered On\n");

if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Device ID: %x%x\n", rxBuffer[0]);
}
else {
System_printf("Device ID fail!\n");
}

if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Device ID: %x%x\n", rxBuffer[0]);
}
else {
System_printf("Device ID fail!\n");
}

System_flush();

----------------------------------------------------------------------------------------------------------------------------------------

  • Hello Vinay,

    I'm not able to debug your code, but I do suggest stepping into the source code (it's all provided!) to further isolate the error. I would also recommend using a i2c bus analyzer to correlate the SW behavior.

    Best wishes