PSoC4 I2C Slave Clock Stretching

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

cross mob
GaryLim
Employee
Employee
10 questions asked First like received 10 replies posted

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.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

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:

AlenAn14_1-1660018825629.png

I have created custom API's i2c_SCL_Stretch_lock() and i2c_SCL_Stretch_unlock() to perform the stretch procedure.

Warm Regards
Alen

 

View solution in original post

5 Replies
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @GaryLim ,

Can you please let me know the PSoC 4 device/ PSOC evaluation kit that you are using for this?

Warm Regards
Alen

0 Likes
GaryLim
Employee
Employee
10 questions asked First like received 10 replies posted

Hello Alen,

 

I am using PSoC4 CY8CKIT-149 which has a PSoC4 4100S Plus.

Thanks.

0 Likes
lock attach
Attachments are accessible only for community members.
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

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:

AlenAn14_1-1660018825629.png

I have created custom API's i2c_SCL_Stretch_lock() and i2c_SCL_Stretch_unlock() to perform the stretch procedure.

Warm Regards
Alen

 

GaryLim
Employee
Employee
10 questions asked First like received 10 replies posted

Thank you very much for your support!

0 Likes
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

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

0 Likes