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.

TM4C123GE6PM: Making the MPU6050 ready to read data from

Part Number: TM4C123GE6PM

In this interesting post:

e2e.ti.com/.../315587

The user came to the conclusion that the MPU6050 isn't released from reset as part of the MPU6050Init function.

He mentioned that he solved the problem - unfortunately, the code hasn't been posted.

Can you please post the required functions that complement MPU6050Init and make the sensor ready to accept read request ? 

  • Hello Shai,

    A TI'er posted that they logged the bug and were looking to have it resolved in the next release. Given that was in 2014, I would have thought that should have been resolved. Have you run into that exact issue?

    It looks like MPU6050Callback has a check for the reset being done:

            //
            // MPU6050 Device reset was issued
            //
            case MPU6050_STATE_INIT_RES:
            {
                //
                // Issue a read of the status register to confirm reset is done.
                //
                psInst->uCommand.pui8Buffer[0] = MPU6050_O_PWR_MGMT_1;
                I2CMRead(psInst->psI2CInst, psInst->ui8Addr,
                         psInst->uCommand.pui8Buffer, 1, psInst->pui8Data, 1,
                         MPU6050Callback, psInst);
    
                psInst->ui8State = MPU6050_STATE_INIT_WAIT;
                break;
            }

  • No,

    I haven't - I'll try and see.

    But if it was solved, somewhere in the MPU6050Init's code there should be a write command to a register that releases it from reset...

    Do you see it somewhere ?

  • Hello Shai,

    My thinking based on reviewing the file is that the fix wasn't added to the Init function, but the Callback function. That is why I posted the above code snippet from Callback, because I believed that is what was added to address the issue.

    However, I had the time to pull down the old 2.0.1 version referenced and did a DIFF of the mpu6050.c file and see that there are no changes between files.

    The engineers who wrote sensorlib and supported it aren't with our team anymore, so it is difficult to support as we lack knowledge of these parts, but my suggestion based on what I see in the code is that if there needs to be a release from reset added to Init then the following code from Callback should be useful (sans the case statement):

            //
            // Status register was read, check if reset is done before proceeding.
            //
            case MPU6050_STATE_INIT_WAIT:
            {
                //
                // Check the value read back from status to determine if device
                // is still in reset or if it is ready.  Reset state for this
                // register is 0x40, which has sleep bit set.  Device may also
                // respond with an address NACK during very early stages of the its
                // internal reset. Keep polling until we verify device is ready.
                //
                //
                if((psInst->pui8Data[0] != MPU6050_PWR_MGMT_1_SLEEP) ||
                    (ui8Status == I2CM_STATUS_ADDR_NACK))
                {
                    //
                    // Device still in reset so begin polling this register.
                    //
                    psInst->uCommand.pui8Buffer[0] = MPU6050_O_PWR_MGMT_1;
                    I2CMRead(psInst->psI2CInst, psInst->ui8Addr,
                             psInst->uCommand.pui8Buffer, 1, psInst->pui8Data, 1,
                             MPU6050Callback, psInst);
    
                    //
                    // Intentionally stay in this state to create polling effect.
                    //
                }
                else
                {
                    //
                    // Device is out of reset, move to the idle state.
                    //
                    psInst->ui8State = MPU6050_STATE_IDLE;
                }
                break;
            }

    From what I can tell in the mpu6050.c file, that seems to be the means to handle that case.