5 Replies Latest reply on May 31, 2014 11:48 AM by user_1377889

    I2C with MPU5060

    user_77989180

       Hi everyone,

         

      I try to use a sensor MPU5060 in I2C but I get some trouble.

         

      In my memories it easy to use I2C with PsoC but It doesn't work :(

         

      My device adresse is 0x68;
      I define  uint8 test=0x43; which is the adresse of MPU6050_GYRO_XOUT_H_REG 
      and     uint8 userArray[10]={0,0,0,0,0,0,0,0,0,0};

         
              
         

      After designed the .CYSCH I write on my code:

         

      I2C_1_Start();

         

      while(1){

         

      I2C_1_MasterClearStatus(); 

         

      2C_1_MasterWriteBuf(MPU6050_ADDRESS , &test, 1, I2C_1_MODE_COMPLETE_XFER );

         

      while (I2C_1_MasterStatus() & I2C_1_MSTAT_XFER_INP);

         

      CyDelay(10);

         

      I2C_1_MasterClearStatus(); 

         

      I2C_1_MasterReadBuf(MPU6050_ADDRESS  , userArray, 1,I2C_1_MODE_COMPLETE_XFER );

         

      while (I2C_1_MasterStatus() & I2C_1_MSTAT_XFER_INP);

         

      CyDelay(10);

         

      val = ((int)userArray[0])*256 + (int)userArray[1];

         

      sprintf(buf, "userArray\t%d\t%d\t%d\t%d\n\r",(int)userArray[0],(int)userArray[1], val, (int)test) ;

         
          UART_1_PutString(buf);   
         

      }

      But It returns nothing :(

         

       

         

      Thank you