51 MCU Study Notes: Summary of 12864 LCD Usage of ST7920 Controller

Publisher:灵感之翼Latest update time:2017-02-19 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Summary:
1. Different control chips may have different LCD interface definitions or register definitions.
2. There are two display modes: parallel and serial. It is said that the serial mode cannot read the data register (DR). Then can the instruction register IR be read?
3. When displaying characters with a font chip, it is not necessary to take the modulus of the characters, but the font may be short of weight, that is, some characters (even commonly used characters) are not in the font. If you encounter the situation that the character is not in the font when you test the code for the first time, it is recommended to buy sports lottery tickets to support sports!
4. The structural address of the chip must be clearly understood. I have read some information on the Internet and found that most of them are inaccurate and even contradictory.
The contents of many data manuals are even more ambiguous and unclear. There are also contradictions between data manuals! 

Based on my own experimental results and combined with some information, I have come to the following conclusions:
ST7920 can control a two-dimensional drawing buffer space of 256×64 dot matrix.
For our 12864 LCD, the GDRAM size is 256*64, It is not that only half of it is used as commonly said on the Internet, but all of it is used.
It includes the visible area and the scrolling visible area. The scrolling visible area is not displayed by default and can only be seen after scrolling.
The visible area corresponds to the upper half of the dot matrix area of ​​GDRAM 256*32, and the scrolling visible area is the lower half of GDRAM 256*32.
Then the GDRAM in the horizontal (128-255) and vertical (0-31) areas of the visible area is mapped to the lower half of the LCD screen.
This is our 12864. I will draw a picture for you to see clearly!

 

 

 

Some more to add:


1. Some online materials give the drawing steps and say that the first step is to set the extended instruction set 0x34. In fact, this depends on the actual situation.
  For example, if you want to play a video or animation, it is very smooth to draw with it turned on

. 2. The dot method is too slow to draw. It is not recommended to use the dot method for full-screen drawing

. 3. Some methods of highlighting. The dot
method is OK for highlighting the rectangular area. It is recommended to make the rectangular range smaller, otherwise it will be slow.
The dot method has a good effect on highlighting text because the rectangular area of ​​the text is relatively small, the speed is very fast, and it does not flicker!
 However, the drawing method is more efficient in highlighting text. If there is sufficient flash space, it is recommended to use the drawing method.

I saw some codes on the Internet. When marking a dot, the 16-bit data of the current address is usually read out first, combined with the dot, and then divided into 2 bytes and written into GDRAM.

In fact, we can improve the efficiency. We only need to read one byte for reading and write one byte for writing. There is no need to read out 16 bits of data and then write them in.

4. Regarding LCD text display,
when LCD displays English and Chinese characters, it should be done in one function. It is completely unnecessary and undesirable to do it in two functions
because one function can directly output full-width and half-width characters, and can output Chinese, English and punctuation marks together.

5. Regarding drawing clearing, the code on the Internet generally clears 256*32, and the lower half of the screen is not cleared. This is OK,
but if you want to scroll the screen, you have to clear it. If you don't clear it, the data is random, and points randomly appear and pop up.

6. I saw a post that used an algorithm to realize scrolling.
 In fact, as long as you understand the address structure and rewrite the setScrollPos method, that is, change a few addresses in the setPos method, you can realize circular scrolling.

If you want flexible scrolling, you can expand the 4 row coordinates in the setPos method to 8 row coordinates, because there should be 8 row coordinates.

The visible area has 4 lines, and the scrollable visible area has 4 lines, and they are continuous.


The above are some of my personal experimental conclusions! I also drew its structure diagram to facilitate the understanding of novices. Please point out any inappropriateness. Thank you! 

Due to different controllers and different models of LCD codes may be different, those codes on the Internet are generally not completely universal.

As long as you understand the relationship between the address structure of the controller and the position of the LCD, you can write out the common functions. If you have any questions, just post them.

Let's communicate together.


Reference address:51 MCU Study Notes: Summary of 12864 LCD Usage of ST7920 Controller

Previous article:51 MCU study notes: merge 1602 and 12864 LCD strip interface
Next article:51 MCU learning notes: timer generates PWM adjustable square wave to control the brightness of LED lights

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号