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.

I2C Transfer Stuck in I2CCC26XX.c at the line 817, Semaphore_pend() during SensorMpu9250 initialization

Other Parts Discussed in Thread: CC2650

Hi,

I have modified the uart_echo code to read the Accelerometer data on PC UART. UART echo code was working fine then I added some necessary files to support MPU9250 initialization. It compiles successfully but hangs during debugging in I2CCC26xx.c file at line no 817

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

Here is my initialization code 

/* Call board init functions */
    Board_initGeneral();
    Board_initUART();
    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 

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

What could be wrong in initialization? 

  • More information is needed here.

    The sensor I2C code was designed solely with the sensortag in mind where the I2C bus is multiplexed between various I2C peripherals (sensor) and the I2C MPU9250.
    Question 1: Are you using a sensortag? If not, I'd recommend to study the "sensor" middleware code and perhaps simplify it by removing the bus multiplexing.
    Question 2: In what context (Task, Swi, Hwi, or even main()) are you calling these APIs? Interrupts are NOT enabled in main(), so you can't pend on a semaphore that is expected to be posted by an ISR. Do this from within a task context.
  • I am using SensorTag CC2650 and I am initializing these function in main. What do you think where should I call SensorMpu9250_init() function. I called it in main because it must be called only once.