Page 4 of 4

Re: ESP32 I2C power/distance problem?

Posted: Mon Mar 26, 2018 10:23 am
by Archibald
antonyc wrote:Just to confirm, it works with the replacement files!
That's really good news.

I have not followed the discussion on GitHub closely, but I am not clear what issue or issues the new library files solve. I get the impression it was problems with real-time multitasking. I've been more focussed on why my I²C fails when I insert a few metres of cable, even when I slow up the clock.

I note in the Technical Reference Manual(page 274):
Users need to configure the values of I2C_SDA_HOLD_TIME and I2C_SDA_SAMPLE_TIME, according to the host characteristics, for the I2C slave to receive data properly.
It would be nice if the Wire library for ESP32 included functions to set these values.
Hexman64 wrote:. . . . . . I cannot observe any change on my scope after using Wire.setClock(10000); . . . . .
Wire.setClock(10000) definitely works here.

Re: ESP32 I2C power/distance problem?

Posted: Mon Mar 26, 2018 7:39 pm
by Hexman64
Wire.setClock(10000) definitely works here.
The command is accepted, but with no effect - I guess you DO observe a change in frequency after changing the clock speed with this command. Strange, I don't.
As my problem is resolved for the moment (I reset the bus as soon as the RTClock returns impossible values), I'll maybe do further setClock testing on the next project, before three different libraries that use the Wire.h are integrated.
I have not followed the discussion on GitHub closely
Me neither, it was some "when this line is high while that line is high during that operation... it fails".
As a much slower bus speed does not resolve your problem, it does not seem like the cable length causes it. Why not give it a try and work through the information on what files to replace and where to get them.

Re: ESP32 I2C power/distance problem?

Posted: Tue Mar 27, 2018 12:33 pm
by Archibald
Hexman64 wrote:Why not give it a try and work through the information on what files to replace and where to get them.
Yes, I intend to get the Wire library working with the new files. Perhaps it's silly but I don't really feel I have things in things in control when I use a library. The issues there have been with the Wire library only reinforce this feeling.

I expect to be using an I²C bus that's about 0.6m long. I don't need multitasking but I would like to be able to wind the speed up above 100kHz.

Re: ESP32 I2C power/distance problem?

Posted: Wed Mar 28, 2018 2:28 pm
by Hexman64
Well, I decided to make my project even more stable yesterday evening and copied over only the 5 files 'stickbreaker' mentioned. That gave a bunch of compiler errors, so I replaced the whole Wire library with this one:

https://github.com/stickbreaker/arduino-esp32

It has been running for about 20 hours now and the bus-error-counter is still zero.
It used to count up 5-10x per day, so I'd say it fixed my bus errors too.