Feather ESP32S3 with CharlieWing stuttering

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ray_hill
 
Posts: 3
Joined: Thu Nov 10, 2022 6:20 am

Feather ESP32S3 with CharlieWing stuttering

Post by ray_hill »

Hello everyone out there,

I got an Adafruit Tripler/Quadrupler (2x2) to kind of organize all my Feathers/FeatherWings. I also bought one of the green CharlieWings. To test it I plugged all in and uploaded the swirldemo.ino (from the Adafruit_IS31FL3731 library) to the ESP32S3 Feather running at 240 MHz using Arduino IDE 2.0.1 as well as 1.8.16. However, the swirl was not running smooth, stuttering in irregular intervals. Running the same code on the Feather ESP32 V2 or HUZZAH32 did not show any stuttering and was super smooth, as you would expect.
I did a timing measurement and found it sometimes hanging for about 300 ms when calling drawPixel(x, y, intensity);.
I tried changing compilation parameters, but the only thing that had an effect was changing the CPU speed: 160 MHz made the stuttering even worse (more stuttering), 80 MHz or lower solved it (no stuttering at all).
Since it was only stuttering when drawPixel(...) was called my guess was it having something to do with the I2C configuration, so I took a look at the Adafruit_IS31FL3731.cpp. When calling begin(); on the object _i2c_dev->setSpeed(400000); is called. So this was my first thing to go for.
Changing the speed to 200000 -> uploading to the S3 @240 MHz -> swirling a bit slower, but no stuttering at all.
Changing the speed to 800000 -> uploading to the S3 -> swirling way faster, but again no stuttering.
Changing the speed to 300000 -> uploading to the S3 -> again no stuttering.
Changing the speed back to 400000 -> uploading to the S3 -> stuttering!!

So, two questions:
Does anybody have an idea, why there is such a "problem" with the speed of 400000 Hz for the I2C communication?
Could there be anything going wrong/broken with setting the speed to 800000 regarding that it runs smoothly?

For now I fixed it by adjusting the mentioned library from
_i2c_dev->setSpeed(400000);
to
#if defined ARDUINO_ADAFRUIT_FEATHER_ESP32S3
_i2c_dev->setSpeed(300000);
#else
_i2c_dev->setSpeed(400000);
#endif


Maybe someone has an explanation..?
Thanks in advance!

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Feather ESP32S3 with CharlieWing stuttering

Post by mikeysklar »

Good job finding a work around. Yes, it is totally bizarre that 300kHz i2c bus speed is smooth and 400kHz wast not.

Since you are using a FeatherWing tripler I should ask if there was any other devices connected besides the Feather ESP32-S3 and CharlieWing?

The datasheet for the CharlieWing mentions 400 kHz as the max speed. Since you are seeing a smooth results when manually entering greater values that is even stranger.

This seems worthy of creating a github issue since you are producing it in stock code.

https://github.com/adafruit/Adafruit_IS31FL3731/issues

User avatar
ray_hill
 
Posts: 3
Joined: Thu Nov 10, 2022 6:20 am

Re: Feather ESP32S3 with CharlieWing stuttering

Post by ray_hill »

Thanks mikeysklar,

I thought this was specific to the ESP32-S3, but I tested the same thing with the OLED FeatherWing (SH1107) at 400 KHz and there everything was smooth.

I actually used the 2x2 Quad FeatherWing Kit and had an empty Proto FeatherWing and a NeoKey FeatherWing plugged in as well, but the NeoKey FW did not make any use of the I2C bus. For the swirldemo, I didn't even include the libs for the NeoPixels, so I guess this is fine.

I will go ahead and create a github issue as you have suggested. Thank you!

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Feather ESP32S3 with CharlieWing stuttering

Post by mikeysklar »

I realize you are using the Feather ESP32-S3, but looking at the Feather ESP32-S2 I did see this. Different chips, might not apply. Maybe you can check with a scope to confirm.

https://learn.adafruit.com/adafruit-esp ... aq-3116099

I2C at 100 kHz bus frequency runs slowly

The default I2C bus clock speed is 100 kHz (100000) . At that rate, the ESP32-S2 will leave 10ms gaps between I2C transactions. This can slow down your I2C interactions considerably, such as when you are controlling a stepper motor with a PCA9685 controller.

Raising the I2C bus frequency to 125 kHz (125000) or higher fixes this problem. If your I2C peripheral can handle higher frequencies, you can use 400 kHz (400000) or even in some cases 1 MHz (1000000).

Note that board.I2C() creates an I2C bus that runs at 100 kHz. The bus frequency cannot be changed.. To create an I2C bus on the default I2C pins that runs at a different frequency, you must use busio.I2C(board.SCL, board.SDA, frequency=).

User avatar
ray_hill
 
Posts: 3
Joined: Thu Nov 10, 2022 6:20 am

Re: Feather ESP32S3 with CharlieWing stuttering

Post by ray_hill »

I myself just own the ESP32-S2 QtPy. Don't know if the Feather version is somewhat different, but with this one, it is smooth as expected. In the meantime I also tried with the ESP32-S3 TFT and another green and a yellow CharlieWing, but the result is always the same. Sometimes it works smooth, but then it suddenly gets so slow, that you can sometimes see the frames update. So, I guess this might be more of an ESP32-S3 issue (even though the oled display worked fine with 400kHz I2C bus speed). Didn't have time to look in the core's documentation, but maybe there is something similar to the S2 bus speed limitation.

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”