I2C LCD display getting corrupted [SOLVED]

Hi BulldogLowell,
First, Thank you for your work on this library.
Second, I had to further increase the delay times in the library to prevent LCD screen corruptions in a large Core program that I wrote. The library worked fine on shorter lengthed programs, but in my program of about 800 lines, I kept getting corrupted LCD output whenever I was connected to the Cloud. At first, I thought the Wifi signal was disrupting the i2c transmission, but after about ten hours of debugging, trying on three different cores and trying many, many work-arounds/fixes (I’m a programmer with 20+ years experience), I discovered the trick was to increase the delay times in LiquidCrystal_I2C_Spark.cpp Now, it works great. What a relief!
Following is the code as changed. I multiplied the listed delays by 10. I imagine that’s longer than necessary, but I’m not worried about slowing my program down by a millisecond.

Best, Yogi

PS I was using 4.7k pull-ups. I ran noInterrupts before invoking the library calls.


void LiquidCrystal_I2C::expanderWrite(uint8_t _data){
Wire.beginTransmission(_Addr);
delayMicroseconds(20);
Wire.write((int)(_data) | _backlightval);
delayMicroseconds(20);
Wire.endTransmission();
delayMicroseconds(20);
}

void LiquidCrystal_I2C::pulseEnable(uint8_t _data){
expanderWrite(_data | (1<<2)); // En high
delayMicroseconds(10); // enable pulse must be >450ns
expanderWrite(_data & ~(1<<2)); // En low
delayMicroseconds(100); // commands need > 37us to settle
}

1 Like