- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am using Modustoolbox version 2.4 with PSoC4 I2C slave library. I am using the I2C (not EZI2C) peripheral library. From the library documentation, I could not locate the information about enabling the I2C clock stretching.
https://infineon.github.io/mtb-pdl-cat2/pdl_api_reference_manual/html/group__group__scb__i2c.html
As my single I2C slave on the I2C bus will take a moment to process the work, clock stretching would be a good way to inform the I2C master to kindly wait for my response. Could you point out to me how can I apply clock stretching during I2C slave processing?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @GaryLim ,
The API's for clock stretching are not available as the I2C SCB block does not provide this feature where the user can manually control the SCL line of the same.
However, there is a workaround where you can configure the SCL line as a GPIO and drive it low inside the interrupt callback after an address match occurs and then set the SCL line to default I2C mode after the callback has finished.
I have attached a sample code demonstrating the same where the ExecuteCommand() function has a 3ms delay during which the SCL line remains in LOW / stretched state.
The below waveform depicts the working:
I have created custom API's i2c_SCL_Stretch_lock() and i2c_SCL_Stretch_unlock() to perform the stretch procedure.
Warm Regards
Alen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @GaryLim ,
Can you please let me know the PSoC 4 device/ PSOC evaluation kit that you are using for this?
Warm Regards
Alen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Alen,
I am using PSoC4 CY8CKIT-149 which has a PSoC4 4100S Plus.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @GaryLim ,
The API's for clock stretching are not available as the I2C SCB block does not provide this feature where the user can manually control the SCL line of the same.
However, there is a workaround where you can configure the SCL line as a GPIO and drive it low inside the interrupt callback after an address match occurs and then set the SCL line to default I2C mode after the callback has finished.
I have attached a sample code demonstrating the same where the ExecuteCommand() function has a 3ms delay during which the SCL line remains in LOW / stretched state.
The below waveform depicts the working:
I have created custom API's i2c_SCL_Stretch_lock() and i2c_SCL_Stretch_unlock() to perform the stretch procedure.
Warm Regards
Alen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for your support!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @GaryLim ,
Glad your query is resolved!
Please feel free to post any queries or issues you may have on Infineon products in the community and we will be happy to help.
Warm Regards
Alen