cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable I2C Clock stretching

JPark.20
Associate II

Hi ST.

I'm using STM32 L4P5 as a Master in I2C.

slave device is slow to write data, so I did the slave device do clock stretching for a moment.

Is there any enable related to clock stretching on L4P5?

If so, what's the way to enable it?

thank you​

1 ACCEPTED SOLUTION

Accepted Solutions
Danish1
Lead II

Everything there is to know about the I2C peripheral for your stm32 is in the Reference Manual for that particular stm32.

If it is anything like stm32l4x6, when the stm32 is the master, it automatically copes with clock-stretching done by slaves.

(There is a bit in I2C_CR1 called NOSTRETCH that controls clock-stretching when the stm32 is a slave, but the Reference Manual explicitly states "It must be kept cleared in master mode.")

If you're using the stm32_cube software wrappers, you'll need to delve into the source code for them to see how that bit is controlled, to make up for inadequate documentation.

Do you have access to an oscilloscope? That way you could easily see if clock-stretching is actually taking place.

What is your slow slave? Many slow devices (I'm thinking of EEPROM) accept the current command at full speed, then indicate they're busy by not ACKing any subsequent command that is sent.

Hope this helps,

Danish

View solution in original post

2 REPLIES 2
Danish1
Lead II

Everything there is to know about the I2C peripheral for your stm32 is in the Reference Manual for that particular stm32.

If it is anything like stm32l4x6, when the stm32 is the master, it automatically copes with clock-stretching done by slaves.

(There is a bit in I2C_CR1 called NOSTRETCH that controls clock-stretching when the stm32 is a slave, but the Reference Manual explicitly states "It must be kept cleared in master mode.")

If you're using the stm32_cube software wrappers, you'll need to delve into the source code for them to see how that bit is controlled, to make up for inadequate documentation.

Do you have access to an oscilloscope? That way you could easily see if clock-stretching is actually taking place.

What is your slow slave? Many slow devices (I'm thinking of EEPROM) accept the current command at full speed, then indicate they're busy by not ACKing any subsequent command that is sent.

Hope this helps,

Danish

Thank you Danish.

I checked and saw that clock-stretching is working using oscilloscope.

As you said, It seems that MCU handles clock-stretching automatically.

I found several Reference Manual, and I was checking if there was a bit for clock-stretching, but I think it was solved simply using the oscilloscope.

It really helped a lot Thank you!!​