3 Replies Latest reply on Dec 9, 2018 8:21 PM by SrinathS_16

    i2c write one byte addressing in Fx3s

    JaYe_3798301

      Hi,

       

      I am trying to get the i2c write working in my Fx3S.

      The Fx3S worked as a i2c master, and my i2c slave device is at one byte addressing mode.

      After modifying the sample code to:

       

          preamble.length    = 2;
          preamble.buffer[0] = IAP2_I2C_WRITE_ADDRESS_RST_HIGH;    
          preamble.buffer[1] = ACCESSORY_CERTIFICATE_SERIAL_NUMBER; //0x4E
          preamble.ctrlMask  = 0x0000;
      
          status = CyU3PI2cTransmitBytes (&preamble, buffer, 1, 0);
      

       

      The i2C waveform I got is as follows:

      How should I correctly set if I do not want the additional 0x00 byte following 0x4E?

        • 1. Re: i2c write one byte addressing in Fx3s
          SrinathS_16

          Hello,

           

          EDIT: Please ignore this response as it is INCORRECT.

           

          Please modify as below.

          status = CyU3PI2cTransmitBytes (&preamble, buffer, 0, 0);

           

          The preamble data contains the address and the first byte of data to be followed. So, the byteCount parameter of the CyU3PI2cTransmitBytes should be set to 0. Since you have set this to '1', there is an additional byte of data after the preamble being sent.

           

          Best regards,

          Srinath S

          • 2. Re: i2c write one byte addressing in Fx3s
            JaYe_3798301

            Hi Srinath,

             

            I've modified the code following your suggestion.

                preamble.length    = 2;  
                preamble.buffer[0] = IAP2_I2C_WRITE_ADDRESS_RST_HIGH;      
                preamble.buffer[1] = ACCESSORY_CERTIFICATE_SERIAL_NUMBER; //0x4E  
                preamble.ctrlMask  = 0x0000;  
              
                status = CyU3PI2cTransmitBytes (&preamble, buffer, 0, 0);  
            
            

             

            However, there would be no i2c waveform out if the 3rd parameter of CyU3PI2cTransmitBytes  is 0.

            And I verified it with my logic analyzer.

            Does the API not accept byteCount to be 0?

             

            Jay

            • 3. Re: i2c write one byte addressing in Fx3s
              SrinathS_16

              Hello Jay,

               

              - Apologies. You are right. The CyU3PI2cTransmitBytes() API would return immediately if the byteCount parameter is set to 0 and there would be no I2C transfer.

              - Modify the preamble buffer to contain the device address (IAP2_I2C_WRITE_ADDRESS_RST_HIGH) and include a data buffer that is passed as a parameter to the CyU3PI2cTransmitBytes. Fill the data buffer with the ACCESSORY_CERTIFICATE_SERIAL_NUMBER and pass it to the CyU3PI2cTransmitBytes() API.

              - When CyU3PI2cTransmitBytes()byteCount parameter is set to 0, there will be no I2c transfer.

               

              Best regards,

              Srinath S