Arduino 101 - very slow LCD update speed

HI,
I have a small project that I need to update (20x4) LCD quickly. Unfortunately Arduino 101 (32 MHz) board very slow compared to UNO board with exactly the same code. Its 10 times slower.

To write 4 lines, 101 takes about 311ms while UNO took only 30 seconds. I am sure 101 has a very slow i2c speed. I updated 101 i2c.c file with I2C_FAST for speed (400 KHz) but seems it does not have any effect here.

Any one could help ?

Thank you,
Pubudu

Hi Pubudu,
which library are you using?

I am using LIquid_Crystal_I2C library. Anyway its calling Intel wire library.

You may want to check out the I2C speed comments I had with a new setclock function: Need a setClock function in Wire Library · Issue #166 · arduino/ArduinoCore-arc32 · GitHub and check this post as well: http://forum.arduino.cc/index.php?topic=397800.0 which shows some speed tests with i2c sensors compared to the mega. Never received a decent reply as to what the i2c issue but there are some other posts on the forum as well discussing I2C issues.

Know this does not help but just thought I would give you some added info that the i2c issue is not new.

Mike

Thank you very much MIke. I will check them. I am kind of frustrated with this. 32 MHz Arduino 101 is much slower than 16 MHz.

So, finally I fixed the issue after going through library files. I thought I should share this with rest of you.
The issue was with the delay used in "i2c.c" file in Arduino 101 library.

The following delay(1) of 1 millisecond is causing delay. So I replaced it with microseconds as follows.
My LCD update time reduced to 22 ms from 311 ms with this change. I think this delay is coming from hardware delays hence need to cautious when changing. I am sure that 1ms is too high.

static int wait_rx_or_err(bool no_stop){
uint64_t timeout = TIMEOUT_MS;
while(timeout--) {
if (i2c_err_detect) {
return I2C_ERROR;
}
if (!no_stop) {
if (i2c_rx_complete) {
return I2C_OK;
}
}
// delay(1);
delayMicroseconds(50);
}
if (!no_stop)
return I2C_TIMEOUT;
else
return I2C_OK;
}

static int wait_tx_or_err(bool no_stop){
uint64_t timeout = TIMEOUT_MS;
while(timeout--) {
if (i2c_err_detect) {
return I2C_ERROR;
}
if (!no_stop) {
if (i2c_tx_complete) {
return I2C_OK;
}
}
// delay(1);
delayMicroseconds(50);
}
if (!no_stop)
return I2C_TIMEOUT;
else
return I2C_OK;
}

Enjoy . . . . . !