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

Announcements

Live Webinar: USB-C adoption. Simple & Cost-efficient solutions | April 18th @9am or 5pm CEST. Register now !

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
NiMc_4245981
Level 3
Level 3
10 replies posted 10 questions asked 5 replies posted

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?

0 Likes
1 Solution

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.

View solution in original post

0 Likes
5 Replies
ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

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

0 Likes
lock attach
Attachments are accessible only for community members.

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

0 Likes
lock attach
Attachments are accessible only for community members.

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

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.

0 Likes

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

0 Likes