Skip to content

I2C wait end of stop before start #883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 28, 2020

Conversation

ABOSTM
Copy link
Contributor

@ABOSTM ABOSTM commented Jan 22, 2020

Summary

Wait for end of I2C STOP before starting a new transfer.

Fixes #864

@matthijskooijman
Copy link
Contributor

At the risk of muddying the waters with an unrelated issue, this might be related ;-). We had an issue where a I2c write followed by an I2c read would result in a timeout for the read for some reason. Adding a delay between the two transactions fixed the problem, so this sounds like it might at least be related.

Here's a trace I made:

image

Green dots are starts, red dots are stops. You can see a stop ollowed by a start at the right, which starts the read transaction. However, it is cut short after the first clock pulse where a stop is done and then nothing happens (until a timeout after 100ms). What's notable is that the one clockpulse that happens is actually 6us rather than 5us as all others are. I suspected this might be the slave stretching the clock, but that did not make too much sense. Reading this, I wonder if maybe somehow the start is done when a (second?) stop is still pending, causing the transaction to start and immediately stop again.

If this report helps clarify things: Great. If it does not make sense, then just ignore it, we'll be more thoroughly investigating this issue on our hardware later (but we need to get a usable release out first next week). I will see if I can quicktly test whether this PR fixes our problem next week.

@ABOSTM
Copy link
Contributor Author

ABOSTM commented Jan 24, 2020

@matthijskooijman,
Thanks for sharing your experiment. Your description corresponds to what I observed while analyzing #864.
So this draft PR could help you (if you are on STM32F1 or STM32F4). You can test it to confirm it is the same issue.

@ABOSTM ABOSTM force-pushed the I2C_WAIT_END_OF_STOP_BEFORE_START branch from be5d074 to 709dbc2 Compare January 28, 2020 08:41
@ABOSTM ABOSTM marked this pull request as ready for review January 28, 2020 08:42
@ABOSTM
Copy link
Contributor Author

ABOSTM commented Jan 28, 2020

Official patch ready for all concerned STM32 families F1, F2, F4 and L1.

@fpistm fpistm self-requested a review January 28, 2020 08:51
@fpistm fpistm added the fix 🩹 Bug fix label Jan 28, 2020
@fpistm fpistm added this to the 1.9.0 milestone Jan 28, 2020
@fpistm fpistm merged commit cc05df9 into stm32duino:master Jan 28, 2020
@matthijskooijman
Copy link
Contributor

We've just tested this on our hardware, and it seems this fix indeed fixes the problem we were seeing as well. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix 🩹 Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

i2c problem with release 1.8.0
3 participants