6 Replies Latest reply on Feb 15, 2016 7:31 PM by adpac_1560036





      Could you please tell me how to send 16 bits of data through I2C?


      I wonder how i should allocate address at the slave for the data transmitted from master.


      Thank you.

        • 1. Re: I2C

          This question can be reduced to "How to access an integer bytewise". There are several different choices.


          some (not all) are:


          You could use a union


          You could directly calculate by shifting and masking


          you could use a type-cast


          Because different MCUs may have different endianess, only the shift and mask method is independent.of that.





          • 2. Re: I2C

            Yeah Bob.


            Should I require to initialise the read buffer at slave separately to read two bytes?


            And also please help me how to send the two bytes from master

            • 3. Re: I2C

              So, what is your I2C master and what is the slave? Provide a datasheet link when not a PSoC. Consider posting your complete project, so that we all can have a look at all of your settings? To do so, use
              Creator->File->Create Workspace Bundle (minimal)
              and attach the resulting file.


              sending bytes will work as


              int Myinteger = 0xBeaf;




                  I2C_MasterWriteByte((void *)(&MyInteger));   // Send upper byte


                  I2C_MasterWriteByte((void *)(&MyInteger)+1);   // Send lower byte





              2 of 2 people found this helpful
              • 4. Re: I2C

                PSoC 3 is Master.


                Im trying to program SI4703 fm receiver through I2C.So, Im unable to know what is happening at the slave. Im not completely done with coding Bob. Il upload a other I2C Master Slave project. Could you please do the changes in them?. Il attach the datasheet of FM receiver too 

                • 5. Re: I2C

                  I prefer using the more basic routines for I2C. Byte I2C interface is quite simple: After setting up the component and starting it you use


                      I2C_MasterSendStart(DeviceAddress,I2C_WRITE_XFER_MODE);    // Initialize a transaction for writing
                      I2C_MasterWriteByte(Value);                // Write to register
                      I2C_MasterSendStop();                    // End of transaction


                  When you want to read from a device you use (example for reading two bytes


                      I2C_MasterSendStart(DeviceAddress,I2C_READ_XFER_MODE);    // Initialize a transaction for writing
                      I2C_MasterReadByte(I2C_ACK_DATA);            // Read from register
                      I2C_MasterReadByte(I2C_NAK_DATA);            // Read from register, last byte is usually NAKed
                      I2C_MasterSendStop();                    // End of transaction


                  Not too difficult. Keep in mind that most of the APIs (except those for reading a byte) return a status byte which, when non-zero indicate an error condition.



                  1 of 1 people found this helpful
                  • 6. Re: I2C

                    Thank you very much!!..


                    Il implement this and try..