Many characters LCD displays use so called HD44780 based protocol on interface. This is more like standard but i recommend to check datasheet from vendor. There can be small modifications and/or difference in timing. Especially timing is important. If communication rate is too quick, then LCD drop data or misbehave depending on internal state. I recommend to check busy flag if possible. If not then correct delay should be applied between commands. Result of commands can be checked via LCD Simulator prior to programing MCU. For example i like this one: DjLCDSIM.
Command Set
Clear Display
RS |
R/W |
|
DB7 |
DB6 |
DB5 |
DB4 |
DB3 |
DB2 |
DB1 |
DB0 |
|
Execution Time
|
0 |
0 |
|
0 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
|
~ 1.52 ms
|
Return Home
RS |
R/W |
|
DB7 |
DB6 |
DB5 |
DB4 |
DB3 |
DB2 |
DB1 |
DB0 |
|
Execution Time
|
0 |
0 |
|
0 |
0 |
0 |
0 |
0 |
0 |
1 |
x |
|
~ 1.52 ms
|
Entry Mode Set
RS |
R/W |
|
DB7 |
DB6 |
DB5 |
DB4 |
DB3 |
DB2 |
DB1 |
DB0 |
|
Execution Time
|
0 |
0 |
|
0 |
0 |
0 |
0 |
0 |
1 |
I/D |
SH |
|
~ 38 us
|
Display ON / OFF Control
RS |
R/W |
|
DB7 |
DB6 |
DB5 |
DB4 |
DB3 |
DB2 |
DB1 |
DB0 |
|
Execution Time
|
0 |
0 |
|
0 |
0 |
0 |
0 |
1 |
D |
C |
B |
|
~ 38 us
|
Cursor or Display Shift
RS |
R/W |
|
DB7 |
DB6 |
DB5 |
DB4 |
DB3 |
DB2 |
DB1 |
DB0 |
|
Execution Time
|
0 |
0 |
|
0 |
0 |
0 |
1 |
S/C |
R/L |
x |
x |
|
~ 38 us
|
Function set
RS |
R/W |
|
DB7 |
DB6 |
DB5 |
DB4 |
DB3 |
DB2 |
DB1 |
DB0 |
|
Execution Time
|
0 |
0 |
|
0 |
0 |
1 |
DL |
N |
F |
x |
x |
|
~ 38 us
|
Set CGRAM Address
RS |
R/W |
|
DB7 |
DB6 |
DB5 |
DB4 |
DB3 |
DB2 |
DB1 |
DB0 |
|
Execution Time
|
0 |
0 |
|
0 |
1 |
AC5 |
AC4 |
AC3 |
AC2 |
AC1 |
AC0 |
|
~ 38 us
|
Set DDRAM Address
RS |
R/W |
|
DB7 |
DB6 |
DB5 |
DB4 |
DB3 |
DB2 |
DB1 |
DB0 |
|
Execution Time
|
0 |
0 |
|
1 |
AC6 |
AC5 |
AC4 |
AC3 |
AC2 |
AC1 |
AC0 |
|
~ 38 ms
|
Read Busy Flag and Address
RS |
R/W |
|
DB7 |
DB6 |
DB5 |
DB4 |
DB3 |
DB2 |
DB1 |
DB0 |
|
Execution Time
|
0 |
1 |
|
BF |
AC6 |
AC5 |
AC4 |
AC3 |
AC2 |
AC1 |
AC0 |
|
~ 0 us
|
Write data to RAM
RS |
R/W |
|
DB7 |
DB6 |
DB5 |
DB4 |
DB3 |
DB2 |
DB1 |
DB0 |
|
Execution Time
|
|
|
|
|
|
|
|
|
|
|
|
|
~ 1.52 ms
|
Read data from RAM
RS |
R/W |
|
DB7 |
DB6 |
DB5 |
DB4 |
DB3 |
DB2 |
DB1 |
DB0 |
|
Execution Time
|
|
|
|
|
|
|
|
|
|
|
|
|
~ 1.52 ms
|
Initialization of display
8-bit mode
4-bit mode