11 Replies Latest reply on Apr 14, 2017 1:59 PM by 10452m_1687176

    I2C Master doesn't work.. need help..

    10452m_1687176

      Hello together,

         

       

         

      i have an SDP601 Sensor http://www.mouser.com/ds/2/682/Sensirion_Differential_Pressure_SDP6x0series_Datas-767275.pdf

         

      The Sensor uses I2C to communicate. I have connected the Sensor to a PSOC 5LP Development Board but it doesn't work. 

         


      #include <project.h>
      #define I2C_SLAVE_ADDRESS    (0x40)
          uint8 temp;
          uint8 status;
          uint8 Sensor_Command = 0xF1;              // Command for Sensor
          uint8 Sensor[3];
          uint8 i= 0;
          uint8 j= 0;
      int main()
      {
          CyGlobalIntEnable; /* Enable global interrupts. */
          LCD_Start();
          I2C_Start();
         
          status = I2C_MasterSendStart(0x40, I2C_WRITE_XFER_MODE);
          if(I2C_MSTR_NO_ERROR == status)   /* Check if transfer completed without errors */
          {         
              status = I2C_MasterWriteByte(Sensor_Command);
          }
          status = I2C_MasterSendStart(0x40, I2C_READ_XFER_MODE);
         
              Sensor[0] = I2C_MasterReadByte(I2C_ACK_DATA);
              status = I2C_MasterStatus();
              Sensor[1] = I2C_MasterReadByte(I2C_ACK_DATA);
              status = I2C_MasterStatus();
              Sensor[2] = I2C_MasterReadByte(I2C_ACK_DATA);
              status = I2C_MasterStatus();
          I2C_MasterSendStop();      /* Send Stop */
          LCD_PrintInt8(Sensor[0]);
          LCD_PrintInt8(Sensor[1]);
          LCD_PrintInt8(Sensor[2]);
       
         
          while(1)
          {
         
          }
      }
       

         

       

         

      I tried many other code but it will not work. What can I do? Can you write working example Code?

         

       

         

      SCL is connected to P0[0] SDA is connected to P0[1]

         

      The LCD is connected to P2[0]-P2[6]