Skip to content
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

I2C hang with very slow I2C slave (pic12f1840@500khz) #2162

Closed
miky2k opened this issue Jun 17, 2016 · 7 comments
Closed

I2C hang with very slow I2C slave (pic12f1840@500khz) #2162

miky2k opened this issue Jun 17, 2016 · 7 comments

Comments

@miky2k
Copy link

miky2k commented Jun 17, 2016

----------------------------- Remove above -----------------------------

Basic Infos

Hardware

Hardware: ESP-07
Core Version: 2.2.0

Description

On very slow device i2c hang SDA low and give strange results 01111001 instead 00111100 .

Settings in IDE

Module: Generic ESP8266 Module
Flash Size: 512K/64K
CPU Frequency: 80Mhz
Flash Mode: qio
Flash Frequency: 40Mhz?
Upload Using: SERIAL?
Reset Method: ck

Sketch

Wire.begin(12,13); //I2C pin
Wire.setClockStretchLimit(2000);

In my software(l is not important) :
Wire.beginTransmission(Addr);
Wire.write(0b00111100);
Serial.println("I2C write---"+String(l));
Serial.println(Wire.endTransmission(1));

Serial Output:

I2C write---4
3

i2c

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@miky2k miky2k changed the title I2C hang with very slow I2C device (pic12f840@500khz) I2C hang with very slow I2C slave (pic12f1840@500khz) Jun 17, 2016
@igrr igrr added this to the 2.4.0 milestone Jun 20, 2016
@me-no-dev
Copy link
Collaborator

any particular reason why your slave does not release SDA?

@miky2k
Copy link
Author

miky2k commented Jun 20, 2016

I disconnect physically only sda from device but bus remain low(esp8266 take bus low),
i know that my device may have bad beauvoir but hang sda is quite strange from a master.

Ok the problem is quite complex (or simple now i found it).
Semms that some libraries initialize Wire with Wire.begin() in costructor resetting clockStretch value ,it is difficult to debug because twi_byte_write not report any protocol error (only ack!).
My propose is to accept only greater timeout than current in twi_setClockStretchLimit ,
not difficult to implement i suppose .
And add -1 to twi_byte_write if protocol error occur (stretch limit occur).

@devyte
Copy link
Collaborator

devyte commented Oct 16, 2017

@igrr this has milestone 2.4.0. However, I don't fully understand the issue, let alone what needs to be fixed in Wire.
Is the issue still relevant?

@miky2k
Copy link
Author

miky2k commented Oct 16, 2017

If you need different clock stretch timings on devices is relevant!

Ad is very simple to implement as i described.

@enjoyneering
Copy link

@d-a-v
Copy link
Collaborator

d-a-v commented May 24, 2018

For reference (link)
I will make a PR for that

unless @enjoyneering you wish to make it with your changes ?

@devyte
Copy link
Collaborator

devyte commented Nov 8, 2019

CC @Tech-TX

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

No branches or pull requests

6 participants