Chat here about code rewrites, mods, etc... with respect to the github project https://github.com/esp8266/Arduino

Moderator: igrr

User avatar
By Barfoos
#63052 I have slightly altered the code (the slaves increment the char by 2), and there seems to be some trouble with the transmission of one of the bits.
The first column is from the Uno, the second column is from the ESP:
Code: Select all11
33
55
77
99
;;
==
??
AA
CC

.
.
.


yy
{{
2
4
6
8
:
<
>
@
B
D
User avatar
By Barfoos
#63064 By changing the clock speed it could get the ESP to transfer even and odd bytes.
I requested a long string and iterated the clock speed (and the prescaler, which I had set to /64 by hand up to now).
I printed the string to the serial port and could see which frequency worked best, as the strings got longer and longer as the frequency changed, before they got scrambled again.

I have now chosen 31000, which I can set without altering the prescaler, and can send strings of 31 chars. I haven't tried 32 yet, but I tried 45, which doesn't work at all. So I just guess there is some intrinsic limit 31<n<45 in the request or write functions on the arduino. Since I only want to transmit a timestamp, 31 should be enough.

Thanks for your help!

(I'll probably be back soon, as I have to switch back to the ESP-01 and new issues will arise ;-) )
User avatar
By bjoham
#63074 Good to hear about your progress!

I can't understand why the master terminates the transfer prematurely, but the clock speed is required to be "low" as you have discovered. The reason is the interrupt latency/jitter in the ESP8266 MCU.

I guess there is room for improvement in this regard as I have implemented everything "straight-forwardly". It would be good to know whether there are limitations in the GPIO-interrupt responses. If I'm not mistaken, the current implementation uses an "SDK" interrupt handler. If so, a "bare-bone" handler might work better.

When I get the time, I will set my second ESP module up on my desk and dig into these details.
User avatar
By Barfoos
#63083 In your first post you said that you were using 14 kHz. The Arduino wire.setClock function only works with values between 400k and 31k, so I employed the prescaler to lower the frequency to values below 31k.

Yesterday I found out that the frequency I chose was to low. Calling wire.setClock(31000L) without manually modifying the prescaler resulted in a frequency that works fine, and IIRC the SCL signal is somewhere close to 14k. I will have another look at the frequency and the prescaler, look for discrepancies between my oscilloscope measurements and the description of wire.setClock and report back if I find something strange.

Thanks again!