Arduino LiquidCrystal Library Bug Report #174181

时间:2023-03-09 18:23:39
Arduino LiquidCrystal Library Bug Report #174181

Arduino LiquidCrystal Library Bug Report #174181

Arduino LiquidCrystal Character LCD Driver Library BUG Report #174181

by Conmajia


Effected Devices

Hitachi HD44780 series LCD drivers

SEIKO EPSON SED1278

SAMSUNG KS0066

NER Japan Radio NJU6408

Issue

LiquidCrystal.createChar function can only create custom characters ONCE. Further call of this function will not effect the CGRAM content. Thus dynamic custom character animation is unable to achieve.

Sample Code

// binary custom characters, contents are omitted
byte heart[8] = {...}  // a heart icon ♥
byte smiley[8] = {...} // a smiley icon ☺

// initialize an LCD, parameters are omitted
LiquidCrystal lcd(...);
lcd.begin(16, 2);
// create a new character
lcd.createChar(0, heart);
// print custom character #1
lcd.write(byte(0));
// create/modify another character
lcd.createChar(0, smiley);
// print modified character #1 (BUG)
lcd.write(byte(0));

Expected output is:

♥☺

Actual output is:

♥♥

Character #1 was not modified.

Possible Reason

[To be confirmed]

Timing issue suspected. The LiquidCrystal library does not considered the BUSY status of LCDs. It is not able to read anything from the LCD controllers but to write into them. Write operation was unstable with HD44780 series drivers by only some delays. Fig.1 shows the timing diagram of write operations.

Arduino LiquidCrystal Library Bug Report #174181
Fig.1 Timing Diagram of Write Operation

Timing parameters in Table 1 should be carefully considered.

Table 1 Timing Parameters

Item Symbol Min Max Unit
Enable cycle $t_\mathrm{cycE}$ $1000$ $-$ $\mathrm{ns}$
Enable pulse width $P_\mathrm{weh}$ $450$ $-$ $\mathrm{ns}$
Enable rise, fall time $t_\mathrm{er}$, $T_\mathrm{ef} $-$ $25$ $\mathrm{ns}$
Address setup time $t_\mathrm{as}$ $140$ $-$ $\mathrm{ns}$
Address hold time $t_\mathrm{ah}$ $10$ $-$ $\mathrm{ns}$
Data setup time $t_\mathrm{dsw}$ $195$ $-$ $\mathrm{ns}$
Data hold time $t_\mathrm{h}$ $10$ $-$ $\mathrm{ns}$

Fix

  1. Manually fix the LiquidCrystal.h and LiquidCrystal.cpp source files. (N/A)
  2. Use an alternative driver library like lcdfx or so.

*I'll publish my lcdfx library later.

The End

Back to top

Arduino LiquidCrystal Library Bug Report #174181