3 Replies Latest reply on Oct 18, 2019 1:58 AM by AlakanandaB_86

    PSoC 4 I2C addressing




      I am working on a project that involves establishing I2C in the below-mentioned order:


      First Stage I2C: PSoC 4 (CY8CKIT-040) [Master] to PSoC 4 (CY8C4014SXI-421) [Slave] on prototype board with all the I/O lines tied to GND or left floating except for the I2C lines (SDA and SCL). In this stage, I am trying to store the register values to the PSoC 4 flash (CY8C4014SXI-421 that is included in my prototype board) using CY8CKIT-040 as master, which will later be relayed to the video decoder in the second stage of I2C from the intermediate PSoC 4 that is present on my prototype board, acting as master in 2nd stage.


      Second Stage I2C: PSoC 4 (CY8C4014SXI-421) [converts to Master] to video decoder [Slave]


      Currently, I am trying to write to a register on PSoC 4 [CY8C4014SXI-421] from PSoC 4 (on CY8CKIT-040) but could see that the slave device didn't receive any of the information even after using pull up resistors for the I2C lines. I have been using 0x08 (default slave address for the PSoC MCU on the prototype board). Also on the PSoC Creator 4.0, I have used a single I2C component configured to Master mode of operation assuming that the software will automatically consider the Master to be the PSoC 4 MCU on the CY8CKIT-040 and the slave mentioned in the code will be considered for the external PSoC 4 device that is not on my prototype board.


      It will be great if someone could advise me on whether PSoC addressing varies for different IC numbers. In this case, I am using CY8C4014LQI-421 (from the CY8CKIT-040) and CY8C4014SXI-421 (from my prototype board).


      Thanks & Regards,

      Nandhini Jayapandian

        • 1. Re: PSoC 4 I2C addressing

          Cypress PSoCs have no fixed I2C adresses. At design time you can fix the address of a slave. I2C masters do not have an address.


          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(Register);                // Indicate which register you want to write to

              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_WRITE_XFER_MODE);    // Initialize a transaction for writing

              I2C_MasterWrite(Register);                // Indicate which register you want to write to


              I2C_MasterReadByte(I2C_ACK_DATA);            // Read from register

              I2C_MasterReadByte(I2C_NAK_DATA);            // Read from register, last byte is 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.


          The high-level APIs must be used in this way:


          Writing to slave Count bytes



          Reading from Slave sending register/command byte first:






          • 2. Re: PSoC 4 I2C addressing

            Hello Bob!


            Thank you very much for the detailed explanation. Like you have mentioned, I am able to read and write if I am using the CY8CKIT-040 to talk directly to a video decoder.


            But since I am using my own prototype board with the other PSoC 4 device (CY8C4014SXI-421) on it, which is not programmed yet, and acts as an external unknown slave device to the CY8CKIT-040, I am unable to program the external PSoC with an address like you have mentioned above, by using an I2C slave component in the PSoC Creator and configure it to the required address.


            Currently, I am only using I2C interface to integrate the external PSoC 4 MCU chip (CY8C4014SXI-421) to the CY8CKIT-040 (SCL -> P1_2, SDA -> P1_3 & GND) lines for implementing the first stage in I2C. So I just thought of getting clarification on how to program an external unprogrammed PSoC MCU chip with the required address so that the CY8CKIT-040 can talk to it using the I2C interface.


            It will be great if you will be able to review and advise me regarding this concern. Thanks again for all your time and support.


            Wish you have a great weekend!


            Best Regards,

            Nandhini Jayapandian

            • 3. Re: PSoC 4 I2C addressing



              Can you please refer to the below link


              Preprogramming PSoC 4 MCU chip (CY8C4014FNI-421AT)