Obsługa wyświetlacza LCD z układem sterowania
HD44780U
flapo213 - elektroda (michwolo@op.pl)
1. Opis sygnałów sterujących
‘E’
– Enable przy przejściu z 1 na 0 umożliwia przepisanie za-
wartości z wejść danych do rejestrów.
‘RS’
– przełączanie rejestrów pomiędzy rejestrem danych a re-
jestrem instrukcji 0 – rejestr instrukcji, 1 – rejestr danych.
‘R/W’
– umożliwia zapianie danych do wyświetlacza bądź
sprawdzenia flag, 0 – zapis do wyświetlacza, 1 – odczyt flag z
wyświetlacza.
DB7...DB0
– wejścia danych / flagi. W trybie 8 bitowym wyko-
rzystwane są wejścia od DB7 do DB0, natomiast w trybie 4 bito-
wym wykorzystywana jest wyłącznie starsza połówka od DB7 do
DB4.
Vsc
– wejście napięcia kontrastu (napięcie zeleżne od napięcia
zasilania wyświetlacza).
Vcc
– napięcie zasilania zależnie od modelu 3,3V lub 5V.
Gnd
– masa napięcia zasilania.
2. Symbole używane przy konfiguracji procesora HD44780U
‘DL’
– szerokość magistrali danych, gdy DL = 0 szerokość 4
bitowa, DL = 1 szerokość 8 bitowa.
‘N’
– liczba wierszy, gdy N = 0 – jeden wiersz, 1 – dwa wier-
sze.
‘F’
– wybór wielkości fonta, gdy F = 0 – 5x8, F = 1 – 5x10.
‘D’
– załączenie / wyłączenie wyświetlacza, gdy D = 0 wy-
świetlacz wygaszony, D = 1 aktywny.
‘C’
– kursor widoczny / niewidoczny, gdy C = 0 niewidoczny,
C = 1 widoczny.
‘B’
– miganie kursora aktywne / nieaktywne, gdy B = 0 – brak
migania, B = 1 – miganie włączone.
‘I/D’
– inkrementacja / dekrementacja, gdy I/D = 1 inkremen-
tacja, I/D = 0 dekrementacja.
‘S’
– przesunięcie, S = 1 przesunięcie aktywne, S = 0 brak
przesunięcia.
3. Algorytm konfiguracji
Start -
Initialization
Start-up power
supply, add delay
5V option 15ms,
3,3V option 40ms
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 = 0, DB5 =
1, DB4 = 1
Insert delay 4,1 ms
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 = 0, DB5 =
1, DB4 = 1
Insert delay 100us
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 = 0, DB5 =
1, DB4 = 1
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 = 0, DB5 =
1, DB4 = 0
Switching to 4 bit
data length interface
Wait to power supply
reach 4,5V or 2,7V
Boot-up procedure of
HD44780 processor
If(DB7 == 1)
R/W = 1
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 = 0, DB5 =
1
, DB4 =
DL
Wait until flage BF will be 1
indicate ready to get new
command
Set on pins RS =
0, R/W=0, DB7 =
N
, DB6 =
F
, DB5 =
1, DB4 = 0
This two block after if condition set up
4 bit interface length and
If DL = 0 set 4 bit interface length , DL = 1 set 8 bit
if N = 0 (1 row) or N = 1 (2 row),
F = 0 (5x8) or F = 1 (5x10)
If(DB7 == 1)
R/W = 1
Wait until flage BF will be 1
indicate ready to get new
command
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 = 0, DB5 =
0, DB4 = 0
Set on pins RS =
0, R/W=0, DB7 =
1
, DB6 =
D
, DB5
=
C
, DB4 =
B
This two block after if condition set up
some display information
If D = 0 display info is turn off , D = 1 display is an active
if C = 0 cursor is turn off or C = 1 cursor is an active,
B = 0 static cursor or B = 1 blinking cursor
Yes
No
Yes
No
If(DB7 == 1)
R/W = 1
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 = 0, DB5 =
0, DB4 = 0
Set on pins RS =
0, R/W=0, DB7 =
1
, DB6 =
D
, DB5
=
C
, DB4 =
B
Yes
No
Rest of initialization is in
on hd44780u_alg02
document
Pierwsza część algorytmu hdd44780u_alg01
Continous from
document
hd44780u_alg01
If(DB7 == 1)
R/W = 1
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 = 0, DB5 =
0, DB4 =
1
Set on pins RS =
0, R/W=0, DB7 =
S/C
, DB6 =
R/L
,
DB5 = x, DB4 = x
Yes
No
Wait to last internal
operation is finished
Set options move cursor or shift display
S/C = 0 cursor move, S/C = 1 display shift
and R/L = 0 shift to left,
R/L = 1 shift to right, x - less worth state
If(DB7 == 1)
R/W = 1
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 = 0, DB5 =
0, DB4 = 0
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 =
1
, DB5 =
I/D
, DB4 =
S
Yes
No
Wait to last internal
operation is finished
Set options cursor move direction
and specifies display shift
I/D = 0 decrement, S/C = 1 increment
and S = 1 add display shift
If(DB7 == 1)
R/W = 1
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 = 0, DB5 =
0, DB4 = 0
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 = 0 , DB5 =
0, DB4 =
1
Yes
No
Wait to last internal
operation is finished
Clear all entire display and sets DDRAM
address to 0 in address counter
3 not described
options please
refer to HD44780u
manual
End of initialization
procedure of
HD44780u
Druga część algorytmu hdd44780u_alg01
4. Algorytm zmiany pozycji na wyświetlaczu.
Start Row Change
Set on pins RS =
0, R/W=0, DB7 =
1
, DB6 =
y
, DB5 =
x
, DB4 =
x
Set on pins RS =
0, R/W=0, DB7 =
x
, DB6 =
x
, DB5 =
x
, DB4 =
x
If(DB7 == 1)
R/W = 1
Yes
No
Exit Row Change
1 indicates operation change DDRAM actual
position, y - position if 0
choose row 1 and if 1 choose row 2, x - is
position on one row
Wait for internal
operation finish
Instruction to save 0x80
row 1 position 1
Instruction to save 0xC0
row 2 position 1
5. Algorytm zapisu znaku na wyświetlaczu.
Start Character
Save
Set on pins RS =
1, R/W=0, DB7 =
x
, DB6 =
x
, DB5 =
x
, DB4 =
x
Set on pins RS =
0, R/W=0, DB7 =
x
, DB6 =
x
, DB5 =
x
, DB4 =
x
If(DB7 == 1)
R/W = 1
Yes
No
End of Save
Character
A
Save Character for
instance ‘A’ is in ASCII
0x65
If You want to save a character to display You should
change RS to 1 and R/W to 0 and x is all position in
ASCII code table for instance character ‘A’ 0x65
6. Algorytm zapisu znaku specjalnego do pamięci znakowej CGRAM
Save New Character
in CGRAM
Set on pins RS =
0, R/W=0, DB7 =
0, DB6 =
1
, DB5 =
x
, DB4 =
x
Set on pins RS =
0, R/W=0, DB7 =
x
, DB6 =
x
, DB5 =
x
, DB4 =
x
If(DB7 == 1)
R/W = 1
Yes
No
End of Save New
Character in
CGRAM
Set on pins RS =
1, R/W=0, DB7 =
x
, DB6 =
x
, DB5 =
x
, DB4 =
x
Set on pins RS =
0, R/W=0, DB7 =
x
, DB6 =
x
, DB5 =
x
, DB4 =
x
If(DB7 == 1)
R/W = 1
Yes
No
If(i == 8)
i++
No
Yes
1 indicate that choose save instruction write to
CGRAM, all x is address to specyfic line, if you want
save 8 point hight character You should in x place
insert I variable (increment)
Wait to the the last internal operation is
finish
Save pattern of new one line character in
CGRAM
Wait to the the last internal operation is
finish
Save the 5x8 character save in CGRAM
0 0 0
0
1
0 0 0
0 0 0
0
1
0
1
0
0 0 0
0
1 1
0 0
0 0 0
0
1
0 0 0
0 0 0
1 1
0 0 0
0 0 0
0
1
0 0 0
0 0 0
0
1 1 1 1
0 0 0
0 0 0 0 0
Character 5x8 pixels
Character polish ‘ Ł’
0x08
0x0A
0xC0
0x80
0x18
0x08
0x0F
0x00
7. Algorytm inicjalizacji wyświetlacza napisany w języku ANSI C
8. Algorytm inicjalizacji wyświetlacza napisany w języku VHDL