2 Replies Latest reply on Oct 23, 2018 3:34 PM by user_80002741

    Help with High-level I2C MasterReadBuff

    user_80002741

      Hello, I'm stuck in trying to get a simple example working that include an I2C Master and I2C Slave. I trying to use the high-level API's to do a MasterReadBuff function call.

       

      void InitializeSystem(void)   //    Start all components, initialize  variables, perform self-test

      {

      uint8 ii;

          CyGlobalIntEnable;

          for(ii = 0; ii < BUFFSIZE; ii++)

          {

         SlaveSendBuffer[ii] = ii;

          }

         

          PWM_Start();

       

          Slave_I2C_SlaveInitReadBuf(SlaveSendBuffer, BUFFSIZE);

          Slave_I2C_SlaveInitWriteBuf(SlaveReceiveBuffer,BUFFSIZE);

      Slave_I2C_Start();   //    Initialize I2C slave

         

          Master_I2C_Start();

         

      PWM_WriteCompare(1);

      }

       

      int main()

      {

      int i,k;
      uint32 MStatus;
      uint8 temp =0;
      uint8 mydata = 1;
      uint8 write_data_buffer[SUB_ADDR_LENGTH] = {SUB_ADDR_LOCATION};

         

          InitializeSystem();

       

      MStatus = Master_I2C_MasterSendStart(SlaveAddr,Master_I2C_WRITE_XFER_MODE);// Initialize a transaction for writing 
          
      Master_I2C_MasterClearStatus();
            
      Master_I2C_MasterReadBuf(SlaveAddr,  Master_Rd_Buffer,   READ_DATA_LENGTH, Master_I2C_MODE_REPEAT_START);
            
      while(0u == (Master_I2C_MSTAT_ERR_XFER & Master_I2C_MSTAT_RD_CMPLT))
            
      temp++;

       

        

      }

       

      I'm having trouble reading from the SlaveReceive Buffer. Can anyone give me some help?

       

      Thanks,

      Joe