HAL_I2C bug?
Posted: Wed Nov 15, 2017 8:06 pm
Using arduino environment with default I2C pin and an I2C LCD display and i2c library LiquidCrystal_I2C_ID1574
The write sequence for 1 byte to the display is
- write first nibble with lCD "enable"off
- write first nibble with lCD "enable"on
- write first nibble with lCD "enable"off
Then same sequence for second nibble.
The sequence of 3 writes for each nibble is quite fast
When using the standard liquid cristal, the I2C hardware fails
The code for standard library is as follows:
void LiquidCrystal_I2C::expanderWrite(uint8_t _data){
Wire.beginTransmission(_Addr);
printIIC((int)(_data) | _backlightval);
Wire.endTransmission();
}
if modifyng the liquid crystal lib by adding a delay, the I2C works fine
Modified lib:
void LiquidCrystal_I2C::expanderWrite(uint8_t _data){
Wire.beginTransmission(_Addr);
printIIC((int)(_data) | _backlightval);
Wire.endTransmission();
// GY endtransmission/I2C seem to return before completion
delay(1);
//gy
}
It looks like the i2cWrite from the esp32 Hal i2c library completes prematurily.
Rgds
Gerard
The write sequence for 1 byte to the display is
- write first nibble with lCD "enable"off
- write first nibble with lCD "enable"on
- write first nibble with lCD "enable"off
Then same sequence for second nibble.
The sequence of 3 writes for each nibble is quite fast
When using the standard liquid cristal, the I2C hardware fails
The code for standard library is as follows:
void LiquidCrystal_I2C::expanderWrite(uint8_t _data){
Wire.beginTransmission(_Addr);
printIIC((int)(_data) | _backlightval);
Wire.endTransmission();
}
if modifyng the liquid crystal lib by adding a delay, the I2C works fine
Modified lib:
void LiquidCrystal_I2C::expanderWrite(uint8_t _data){
Wire.beginTransmission(_Addr);
printIIC((int)(_data) | _backlightval);
Wire.endTransmission();
// GY endtransmission/I2C seem to return before completion
delay(1);
//gy
}
It looks like the i2cWrite from the esp32 Hal i2c library completes prematurily.
Rgds
Gerard