I’ve been building a project using PlatformIO and the ESP32 on a custom board.
I’m interfacing an LED matrix using a matrix driver that communicates over I2C. The issue that I am facing is that for some reason there is a big delay between consecutive I2C transfers (write only) that is causing very poor refresh rate. This using the Wire library.
And then sending the data over to the I2C bus using the wire library:
for(int i = 0; i<tail; i++)
I2CWriteByte(addr, i2cAddrbuffer[i], i2cCMDbuffer[i]);
I’ve hooked up my scope and captured some screenshots to made it easier to show what’s happening:
Is this an inherent problem with the Wire library? Should I use the original ESP I2C library?
I thought that this could be an issue that could be caused by task switching from FreeRTOS (I’m running this code on the Setup function) but lowering the freertos scheduler frequency didnt help.
The Wire library seems to have some significant overhead in its drivers, looking at places like here and more importantly the I2C write functions and sub-calls like this, so 62 microseconds overhead between I2C transmissions doesn’t seem that absurd…
Also page 8 of the datasheet shows the "Writing to IS31FL3741 (Automatic address increment) " which should be what you want and the way to go to overcome the driver-overhead. Give the I2C driver the biggest possible continuous buffer it can handle and if it writes it efficiently (only big setup functions at the beginning of a multi-byte tranmissions) it should increase performance significantly.
Yes! I noticed that, I am running the Wire library with that same configuration. And like you said, it doesen’t help.
It was only when i tested the usual transfer without the unlocking command that I started to get better results. That led me believe that i could do the transfer of all of the registers of one page in one go (if the buffer allows it). I’m am still exploring this option but I think I will replace the Wire library with the IDF, that seems more robust.
Anyway, I appreciate the help and support, have a great day!