The display principle of dot matrix LCD screen
In the digital circuit, all the data conditions are saved with O and 1, for the LCD controller to perform different data operations, you can get some different results. For the operation of displaying English, since there are fewer types of English letters, only 8 bits (one byte)) are needed. For Chinese, there are more than 6000 commonly used, so our DOS predecessors thought of a solution, which is to use two of the 128 rarely used values in the ASCII table to represent Chinese characters, that is : The inner code of Chinese characters. The remaining low 128 bits are reserved for English characters, namely: English internal code.
Then, after the internal code of the Chinese character is obtained, it is only a set of numbers. How to realize the screen display? Then this involves the font of the text. Although the font is also a set of numbers, its meaning is different. The meaning of numbers has fundamentally changed. It is using the individual information of the numbers to record the shape of English or Chinese characters. For example, the way the English "A" is recorded in the font is shown in Figure 1 below:

Figure 1 "A" font diagram
The Chinese "you" is recorded in the font as shown in Figure 2:

Figure 2 "You" font map
Introduction to 12864 dot matrix LCD screen
12864 is a graphic dot matrix LCD screen, which is mainly composed of row driver/column driver and 128×64 full dot matrix LCD screen. It can complete the display of graphics, and can also display 8x4 (16×16 dot matrix) Chinese characters.
Pin No. Pin Name LEVER Pin Function Description
vss
o Power Ground
2
VDD
+5.0V power supply voltage
3
vo
LCD drive voltage
4
D/I(RS)
D/I="H", means DB7~DBO are display data
H/L one
D/I=“L”, it means that DB7~DBO is the display command data R/W=“H”, E=“H” The data is read to DB7~DBO
5
R/W
H/L
R/W= "L", E="H→L" data is written to R or DRR/W="L", the falling edge of E signal is latched DB7~DBO
6
E
H/L
R/W="H", E="H" DDRAM data is read to DB7~DB0
7
DBO
H/L
Data line
8
DB1
H/L
Data line
9
DB2
HAL
Data line
10
DB3
H/L
Data line
11
DB4
H/L
Data line
12
DB5
H/L
Data line
13
DB6
H/L
Data line
14
DB7
H/L
Data line
15
CS1
H/L
H: Select chip (right half screen) signal
16
CS2
H/L
H: Select chip (left half screen) signal
17
RET
H/L
Reset signal, low level reset
18
VOUT
-10V
LCD drive negative voltage
19
LED+
LED backlight board power supply
20
LED-
LED backlight board power supply
Table 1: Pin description of 12864LCD screen
Before using the 12864LCD screen, you must first understand the following functional devices before you can program. The internal functional devices and related functions of the 12864 are as follows:
1. Instruction Register (IR)
IR is used to register the instruction code, corresponding to the data in the data register. When D/I=0, the instruction code is written into lR under the effect of the falling edge of the E signal.
2. Data Register (DR)
DR is used to register data and corresponds to the register instruction of the instruction register. When D/I=1, the graph display data is written into DR under the action of the falling edge, or read from DR to the DB7~DBO data bus under the action of the high level of the E signal. The data transmission between DR and DDRAM is automatically executed inside the module.
3. Busy sign: BF
The logo of BF is to provide internal working conditions. BF=1 means that the module is operating internally, and the module will not accept external instructions and data at this time. When BF=O, the module is in a ready state and can accept external instructions and data at any time.
Make good use of the STATUS READ instruction, you can read BF to the bus of DB7, and verify the working status of the module. 4. Display control trigger: DFF
This trigger is used to control the on and off of the module's screen display. DFF=1 means the display is on (DISPLAY OFF), the content of DDRAM will be displayed on the screen, and DFF=0 means the display is off (DISPLAY OFF).
The state of DDF is controlled by the command DISPLAY ON/OFF and RST signal.
5. XY address counter
The XY address counter is a 9-bit counter. The upper 3 bits are the X address counter, and the lower 6 bits are the Y address counter. The XY address counter is actually the address pointer of DDRAM, the X address counter is the page pointer of DDRAM, and the counter of Y address is the Y address pointer of DDRAM.
The X address counter has no counting function and can only be set by instructions.
The Y address counter has the function of cyclic counting. After each display data is written, the Y address is automatically incremented by 1, and the Y address pointer is from 0 to 63. 6. Display data RAM (DDRAM)
DDRAM is used to store graphics display data. A data of 1 means display selection, and a data of 0 means display non-selection. The relationship between DDRAM and address and display position is detailed in the DDRAM address table.
7. Z address counter
The Z address counter is actually a 6-bit counter. This counter has a cyclic counting function. It is used to display line scan synchronization. When the scan of one line is completed, the counter of this address will automatically increase by 1, pointing to the scan data of the next line. The Z address counter will be 0 after RST reset.
The counter of the Z address can be preset with the command DISPLAY START LINE. Therefore, the starting line of the display screen is controlled by this instruction, that is, where the DDRAM data starts to be displayed on the first line of the screen. The DDRAM of this module has a total of 64 lines, and the screen can scroll through 64 lines.
12864LCD command system and timing
The command system of this type of liquid crystal display module (ie: KSO108B and its compatible control driver) is relatively simple, and there are only seven types in total. The instruction list is shown in the following table:
Control signal control code
Command name
R/W RS DB7 DB6 DB5DB4 DB3 DB2 DB1 DBO
Display switch
o0oo111111/0
Display starting line setting 001 1 xXxxxx page setting
o01 0111Xxx
Column address setting
oo01xXxxxx
Read status
1oBuSY oON/OFFRST oooo
Write data
o1 write data
Read data
11 read data
Table 2: Instruction list of 12864 LCD screen
Each function command is introduced as follows. ·Display on/off instructions
R/WRSDB7DB6 DB5 DB4 DB3DB2DB1 DBO0000111111/0
When DBO=1, LCD displays the contents of RAM; when DBO=O, the display is turned off. 2. Display the start row (ROW) setting instruction
R/WRSDB7DB6 DB5 DB4 DB3DB2DB1 DBOo011 Display start line (0~63)
This command sets the line number of the display RAM corresponding to the top line of the LCD screen, and changes the display of the marriage line regularly, which can make the LCD display scrolling effect.
3. Page (PAGE) setting command
R/WRS DB7 DB6 DB5 DB4 DB3DB2DB1 DBOo010111 Page number (0~7)
The display RAM has 64 lines, divided into 8 pages, each with 8 lines. 4. Column address (Y Address) setting instruction
R/WRSDB7 DB6 DB5 DB4 DB3DB2DB1 DBOo0
01 Display column address (O~63)
Setting the page address H and the column address uniquely determines a cell in the display RAM, so that the MPU can use read and write commands to read the content of the cell or write a byte of data to the cell.
5. Read status command
R/WRS
DB7 DB6 DB5 DB4 DB3DB2DB1 DBO
10
BUSYOON/OFFREST000o
This command is used to query the status of the internal controller of the LCD module, and the meaning of each parameter is as follows: BUSY:1-internal working O-normal status
ON/OFF: 1-display off 0-display on RESET: 1-reset state 0-normal state
In the state of BUSY and RESET, in addition to the read state instructions, other instructions will not have any effect on the LCD module. Before operating the liquid crystal display module, it is necessary to query the BUSY status to determine whether the liquid crystal display module can be operated.

