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.

What is calling sequence of I2C and MPU9250 function to read accelerometer data

Other Parts Discussed in Thread: CC2650

Hi,

I want to read MPU9250 Accelerometer data and I am initializing it as following but I am program hangs in Mpu9250_init().

    Board_initGeneral();
    retParams = SensorI2C_open();
    retParams = SensorMpu9250_init();
    SensorMpu9250_enable(0x0F); //Acc+Gyro+Mag+WoM+-2g
    retParams = SensorMpu9250_accRead((uint16_t *)sensorData);

Can someone tell me what am I doing wrong here? 

  • Hi,

    Maybe you should not call SensorMpu9250_init() immidiately after SensorI2C_open(), if the I2C isn't ready yet. What hardware are you running this code on? Can you debug further to see exactly where it hangs?

    Best Regards

    Joakim

  • I am using SensorTag CC2650 and I added some necessary files to support MPU9250 initialization. It compiles successfully but hangs during debugging in I2CCC26xx.c file at line no 817

    1
    2
    /* Acquire the lock for this particular I2C handle */
      Semaphore_pend(Semaphore_handle(&(object->mutex)), BIOS_WAIT_FOREVER);

    Here is my initialization code 

    1
    2
    3
    4
    5
    6
    7
    /* Call board init functions */
        Board_initGeneral();
        retParams = SensorI2C_open();
        retParams = SensorMpu9250_init();
        SensorMpu9250_enable(0x0F); //Acc+Gyro+Mag+WoM+-2g
        retParams = SensorMpu9250_accRead((uint16_t *)sensorData);

    It stuck at SensorMpu9250_init() but when I debug it and went inside files to file to find out where it is causing the problem. I have found it hangs at 

    1
    2
    /* Acquire the lock for this particular I2C handle */
      Semaphore_pend(Semaphore_handle(&(object->mutex)), BIOS_WAIT_FOREVER);

    What could be wrong in initialization? 

  • I tried to add

    CPUdelay(8000*100);

    But did not work.

  • I would like to know what the situation of the matter is now.