MOD-RGB [MicroPython Porting] : I2C communication stability - ETIMEDOUT

Started by mchobby, October 15, 2018, 04:42:30 PM

Previous topic - Next topic

mchobby

HI,
I'm porting UEXT modules to MicroPython. I'm Using them with ESP8266-EVB.
See this article about how to install MicroPython on ESP8266-EVB
https://arduino103.blogspot.com/2018/09/micropython-on-esp8266-evb-evaluation.html

I'm currently working on MOD-RGB (writing the modrgb micropython library) and it works pretty well until I do stress it a little bit.
See the modrgb MicroPython code on github for reference:
https://github.com/mchobby/esp8266-upy/tree/master/modrgb

So I write a pretty simple "stress.py" script that just change the color of MOD-RGB and show iteration number.

from machine import I2C, Pin
from time import sleep_ms
from modrgb import MODRGB
from rgbfx import randrange

i2c = I2C( sda=Pin(2), scl=Pin(4) )
rgb = MODRGB( i2c ) # default address=0x20
rgb.pwm( True )

iter = 0
print( 'MOD-RGB start I2C stress test' )
while True:
    color = (randrange( 255 ), randrange( 255 ), randrange( 255 ) )
    iter += 1
    print( 'Iteration %s with color %s' % (iter, color))
    rgb.set_rgb( color )


If I unactive the PWM output with "rgb.pwm( False )" then I can made over 50000 iteration without issue! So the MOD-RGB receive the I2C commands and sends ACK accordingly.

If I do active the PWM output with "rgb.pwm( True )" then MOD-RGB produce light and I shortly got I2C crash with the message "OSError: [Errno 110] ETIMEDOUT".
The I2C bus is completely Out-of-Order.
The crash may occurs after 23 or 134 or 38 or 562 or 24 or 72 iteration. Unpredictable!

Why do I think that MOD-RGB is the cause?
When I do power cycle the MOD-RGB (12V Power input), the I2C communication is recovered until the next ETIMEDOUT!
When PWM is disabled on MOD-RGB, I got no issue on I2C communication.
The MOD-IO and MOD-IO2 are working perfectly with similar code.

What's about ETimedOut?
I do not have logical analyzer to check the issue on the bus. It suggest an issue with latency on the I2C bus.
Someone could he have a check of possible timing issue with the SDA/SCL?

Board revision
Boad has been received on oct. 2018. The PCB is mentionning

Some help or hint would be appreciated.