- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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