源自於 http://www.geocities.com/dinceraydin/lcd/commands.htm
LCD Commands
The commands for HD44780 chip are shown in the table below. Scroll down to see the commands in binary, and more info on the entry mode set command.
INSTRUCTION
|
Decimal
|
Hexadecimal
|
Function set (8-bit interface, 2 lines, 5*7 Pixels) |
56
|
38
|
Function set (8-bit interface, 1 line, 5*7 Pixels) |
48
|
30
|
Function set (4-bit interface, 2 lines, 5*7 Pixels) |
40
|
28
|
Function set (4-bit interface, 1 line, 5*7 Pixels) |
32
|
20
|
Entry mode set |
|
|
Scroll display one character right (all lines) |
28
|
1E
|
Scroll display one character left (all lines) |
24
|
18
|
Home (move cursor to top/left character position) |
2
|
2
|
Move cursor one character left |
16
|
10
|
Move cursor one character right |
20
|
14
|
Turn on visible underline cursor |
14
|
0E
|
Turn on visible blinking-block cursor |
15
|
0F
|
Make cursor invisible |
12
|
0C
|
Blank the display (without clearing) |
8
|
08
|
Restore the display (with cursor hidden) |
12
|
0C
|
Clear Screen |
1
|
01
|
Set cursor position (DDRAM address) |
128 + addr
|
80+ addr
|
Set pointer in character-generator RAM (CG RAM address) |
64 + addr
|
40+ addr
|
Read DDRAM/CGRAM & Check Busy Flag |
|
|
This command sets cursor move direction and display shift ON/OFF. There are 4 possible function set commands;04, 05, 06, and 07. This command changes the direction the cursor moves by setting the address counter to increment or decrement. This command is very important. If you do not understand it you may not see anything or what you actually wanted to see on LCD screen. I have created 4 animated gifs to demonstrate what the function set command is all about.
When my friend Hakan Dereli wanted to learn about LC displays I gave him an LC display and the 4*4 keyboard that I used with my Z80 system.The keyboard is based on a 74C922 chip and my circuit to convert the 4 bit data output of the 74C922 to 8 bit data.It also has 3 other buttons on it.This makes it great to experiment with LCDs by entering commands/data manually. Hakan tested all possible commands by sending all the numbers between 00h and FFh to the LCD to see if there is an undocumented feature and see how all commands work. He did not find anything undocumented, but he noted how LCD behaves after each function set command.
Below are the gifs to demonstrate those commands. To demonstrate the effect of each function set command it is assumed that the LCDs below are 2*16 LC Displays with DD RAM address set to 8 and underline cursor ON. Note that when the address counter is set to DECREMENT, strings sent to the LCD will be printed in reverse order. The same thing applies to the CG RAM, as well.
Entry mode set command 04h
| Decrement Address Counter
Display Shift :OFF
String:Dereli |
Entry mode set command 05h
| Display Shift :ON
Decrement Address Counter
String :Hakan |
Entry mode set command 06h
| Display Shift :OFF
Increment Address Counter
String:Dereli |
Entry mode set command 07h
| Display Shift :ON
Increment Address Counter
String:Hakan |
To check the state of the busy flag and read the address counter
- Set R/W Pin of the LCD HIGH(read from the LCD)
- Select the instruction register by setting RS pin LOW
- Enable the LCD by Setting the enable pin HIGH
- The most significant bit of the LCD data bus is the state of the busy flag(1=Busy,0=ready to accept instructions/data).The other bits hold the current value of the address counter.
*This is a 1-micro-second instruction.
Complete command reference:
Follow these links to navigate through my LCD related pages:
|
|
Graphics LCD: (Based on: KS0108, HD61202 and similars...)
|
沒有留言:
張貼留言