5 Replies Latest reply on Jul 4, 2019 12:20 AM by ShifangZ_26

    I can't get I2C slave to work with CCG3.

    NiMc_4245981

      I've been trying to communicate with the CCG3 using I2C.  The CCG3 is the slave and an FX3 is the master.  I've add the SCB block to TopDesign.cysch and configured it as I2C slave.  Here is my initialization code:

       

      FX3_I2C_I2CSlaveInitReadBuf((uint8_t*)g_i2c_read, I2C_BUFFER_SIZE);

      FX3_I2C_I2CSlaveInitWriteBuf((uint8_t*)g_i2c_write, I2C_BUFFER_SIZE);

      FX3_I2C_SetCustomInterruptHandler(fx3_i2c_cb);

      FX3_I2C_Start();

       

      Then, I periodically call FX3_I2C_I2CSlaveStatus(); to see if there is anything to handle.  This always returns 0.  When I look at the I2C lines with a logic analyzer, I see the address is sent correctly, followed by NAK.  I expected the CCG3 to respond with an ACK.  Also, my custom interrupt handler isn't called.  This means that the interrupt service routine was never called.  What do I need to do to get I2C slave working?

        • 1. Re: I can't get I2C slave to work with CCG3.
          ShifangZ_26

          Hi ,

           

          Could you please kindly share your CCG3 firmware source code in this threads? So that we can test it on our end with CY4531 and reproduce your problem.

           

          Best Regards,

          Lisa

          • 2. Re: I can't get I2C slave to work with CCG3.
            NiMc_4245981

            I've attached a project.  I expect that when I send an i2c command, it will be ACK'd and I will see "." in the UART output indicating that the interrupt was called.  I don't see either.

             

            Here is the logic analyzer showing the address that is sent.

            i2c.png

            • 3. Re: I can't get I2C slave to work with CCG3.
              ShifangZ_26

              Hi ,

               

              I have verified a simple project with your requirements, the test results show the

               

                  /* Start the I2C Slave */

                  I2CS_I2CSlaveInitReadBuf (i2cReadBuffer,  BUFFER_SIZE);

                  I2CS_I2CSlaveInitWriteBuf(i2cWriteBuffer, BUFFER_SIZE);

                  I2CS_Start();

               

               

                  SW_Tx_UART_1_Start();

                  SW_Tx_UART_1_PutChar('a');

               

               

                  I2CS_SetCustomInterruptHandler(Test_int_i2c);

               

              It is working well. I will add this in CCG3 notebook and test it again.

               

              Best Regards,

              Lisa

              1 of 1 people found this helpful
              • 4. Re: I can't get I2C slave to work with CCG3.
                NiMc_4245981

                I was able to get it to work in the notebook example on the CY4531 kit if I turned SYS_DEEPSLEEP_ENABLE off.  I suspect my problem was the chip went to a sleep mode when I was trying to use I2C.

                 

                I tested your code by replacing the main() function in the notebook example.  This worked.  Then when I moved to the old main() function from the notebook example it didn't work.  I started removing stuff from the main() function and the call the system_sleep() appears to be the issue.

                • 5. Re: I can't get I2C slave to work with CCG3.
                  ShifangZ_26

                  Hi ,

                   

                  You could add below to register I2C wake-up function if you do not want to disable deep sleep feature.

                  ------------------------------------------------------------------------------------------------------

                  status = (EZI2C_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_BUSY);

                    if (0u == status)

                    {

                    EZI2C_Sleep();

                    /* Device sleep entry. */

                    CySysPmDeepSleep();

                    EZI2C_Wakeup();

                    }

                  --------------------------------------------------------------------------------------------------------

                   

                  Best Regards,

                  Lisa