If new Chinese characters are added, the maintenance of the Chinese character library will also become a problem. Some handheld tools in our daily life, such as mobile phone quick translation, can input Chinese characters arbitrarily, which is not only flexible but also fast in retrieval. The main reason for this is that the hardware Chinese character library is solidified in these devices. The development of semiconductor technology has greatly reduced the price of large-capacity FLASH ROM, thereby greatly reducing the cost of instruments and equipment using hardware Chinese character libraries. Therefore, more and more technical developers have begun to pay attention to hardware Chinese character libraries, hoping to design and use hardware Chinese character libraries in their own developed equipment to achieve the purpose of accelerating product development and reducing software costs.
1. Knowledge about hardware Chinese character library
1 Chinese character machine code national standard code and area code
In the text files of PC, Chinese characters are stored in the form of machine codes. Each Chinese character occupies two bytes in length. In order to distinguish it from ASCII code, the range starts from 0A1H in hexadecimal and is less than 80H for ASCII code. The highest bit of each byte of the machine code is masked and then displayed in hexadecimal form to form the national standard code. Subtract 0A0H from each byte of the machine code and then display it in decimal, which is the area code of the Chinese character. For example, the national standard code and area code of the word "国" are shown in Table 1.
Table 1 National standard code and area code of the word
"国"
Category Value High Byte Low Byte
Machine code B9FAH 1 0 1 1 1 0 0 1 1 1 1 1 1 0 1 0
National standard code 397AH 0 0 1 1 1 0 0 1 0 1 1 1 1 0 1 0
Area code 195AH 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 0
That is, the area code machine code 0A0AOH For the word "国", the relationship between its area code and machine code is
195AH Area code 0B9FAH Machine code 0A0A0H
Remembering this relationship is the key to our understanding of the following procedures
2 National Standard Chinese Character Set and Area Codes
According to the study of the frequency of use of Chinese characters, Chinese characters can be divided into about 100 high-frequency characters, about 3,000 commonly used characters,
about 4,000 less commonly used characters, about 8,000 rare characters, and about 45,000 dead characters, that is, the number of Chinese characters in normal use reaches 15,000. In 1981, China
announced the basic set of Chinese character sets for communication and its exchange code standard GB2312-80, which combined high-frequency characters, commonly used characters and less commonly used characters into a basic Chinese character set with a total of 6763 characters. In this character set, Chinese characters are divided into 3755 first-level Chinese characters according to their frequency of use, 3008 second-level Chinese characters sorted by pinyin, and 700 Western letters, numbers, graphic symbols, etc. sorted by radicals. The national standard Chinese character set GB2312-80 is provided in the form of a Chinese character library in the Chinese character operating system. The structure of the Chinese character library is uniformly specified as shown in Figure 1.
The pictures related to this topic are as follows:
The character library is divided into 94 areas, each area has 94 Chinese characters, and each Chinese character has a certain area and position in the Chinese character library. The numbering uses two bytes, which is the so-called area code. The first byte of the area code represents the area code, and the second byte represents the position number. Therefore, as long as the area code is known, the address of the Chinese character in the character library can be known. Each Chinese character is stored in the font library in the form of a dot matrix font. For example, a 16x16 dot matrix is generally used. Each dot is represented by a binary bit. When a dot with a value of 1 is displayed, a bright spot can be displayed on the screen. When a dot with a value of 0 is displayed, it is not displayed on the screen. In this way, the 16 16 dot matrix information of a certain character is directly used to display on the display according to the above principle. The corresponding Chinese character, such as a 16 16 dot matrix font of a national character, will appear as shown in Figure 2. When the font information is stored in a storage unit, 32 bytes of address are required. The byte value corresponding to the font is written on the right side of Figure 2.
The pictures related to this topic are as follows:
3 LCD display module characteristics and font data
Chinese character display is one of the purposes of applying graphic LCD display modules in China. At present, most technicians who are more concerned about the hardware Chinese character library want to apply it to the graphic dot matrix LCD display. However, most of the information about LCD display currently introduces how the dot matrix data taken out by the font software is sent to the LCD display. Therefore, the author makes a comparison here. To display this dot matrix graphic on the LCD screen, the corresponding dot matrix data needs to be sent to the LCD display driver. However, for different LCD display drivers, the order of data to be sent to display the same graphic may be different. The author has used LCD display modules with built-in D61202U LCD display driver controller and built-in T6963C LCD display driver controller. The dot matrix
data required to display 16 16 dot matrix Chinese characters are as follows:
HD61202U
DB 000H, 0FEH, 002H, 00AH, 08AH, 08AH, 0FAH
DB 08AH,08AH,08AH,00AH,002H,0FEH,000H,000H
DB 000H,0FFH,040H,048H,048H,048H,048H,04FH
DB 048H,049H,04EH,048H,040H,0FFH,000H,000H
Due to the characteristics of HD61202U display memory, the Chinese character library in the computer cannot be used directly. It needs to be rotated 90 degrees before writing. That is, some font software such as zimo22.exe can be downloaded for free at www.c51bbs.com and set to vertical reverse order to obtain the data. The format of the generated font library is that the first 16 bytes are the upper half 16 8 dot matrix font data and the last 16 bytes are the lower half 16x8 dot matrix font data. If the reader is consistent with Figure 2 By comparing the corresponding data in, we can see that the connection between the two cannot be seen from the data alone. If the hardware Chinese character library is to be used on this LCD display, the dot matrix information read out must be processed before it can be sent out for display, which increases the difficulty of use.
T6963C
DB 000H, 000H, 07FH, 0FCH, 040H, 004H, 05FH, 0F4H
DB 041H, 004H, 041H, 004H, 041H, 004H, 04FH, 0E4H
DB 041H, 044H, 041H, 024H, 041H, 024H, 05FH, 0F4H
DB 040H, 004H, 040H, 004H, 07FH, 0FCH, 040H, 004H
These data are also obtained through the font software. The reader then compares them with the 32 Comparing the data, we can see that the two are consistent in value and arrangement order. It is this characteristic that makes the author choose the LCD display module with built-in T6963C as an example to discuss the development of hardware Chinese character library.
2. Production of Chinese Character Library
In this section, the author will discuss the specific method of burning the 16 16 dot matrix Song style Chinese character library into the 256KB memory, which is also a question that readers are more concerned about. In this example, AT29C020 is used. This product is a 256KB FLASH ROM produced by ATMEL. Readers can also use other products with a capacity of not less than 256KB, but in the specific circuit design, attention should be paid to the pin definition and logical relationship, and the corresponding model should be selected when burning. UCDOS software has a file named HZK16, which is the 16 16 national standard Chinese character dot matrix file. In this file, according to the Chinese character area code from small to large, all Chinese characters in the national standard area code are stored in order: each Chinese character occupies 32 bytes, and each area is 94 Chinese characters. If its properties are displayed, its size can be seen to be 262KB. When writing to AT29C020A, the part exceeding 256KB can be cut off. In fact, in the national standard Chinese character dot matrix font library, the second-level Chinese characters are arranged in the 87th area, and the 88th area is blank, so cutting off the excess part will not affect the actual use. In actual operation, the production of hardware Chinese character library is no different from the programming of ordinary program memory. Note that when calling in the HZK16 file, you must use binary mode to open the programming and verify successfully, then you can remove the memory for standby, and then a hardware Chinese character library is made. For different applications, readers can also choose other large-capacity or even serial data storage devices to expand the scope of use of the hardware Chinese character library. Here, we also recommend that the storage device with a capacity of 512KB or even larger can not only store all national standard Chinese characters, but also store 8+16 ASCII code dot matrix data and Chinese character sentence encoding data, which is more convenient to use. Serial data storage devices such as AT45DB041B are characterized by occupying fewer ports, small size and low cost. If the speed requirement is not very high, it is very suitable.
Three hardware Chinese character library using circuit
In this section, the author uses the PHILIPS product P89C51RD2 as the main control CPU, uses the 240x128 dot matrix graphic LCD with built-in T6963 controller and combines the use of hardware Chinese character library to embed a novel of more than 30,000 words into it, and can read the novel after booting. P89C51RD2 is a very excellent single-chip microcomputer released by PHILIPS in 2001. This single-chip microcomputer is a derivative product based on the 8-bit 80C51 single-chip microcomputer. It has undergone many aspects of strengthening, expansion, renovation and innovation outside the framework of the 80C51 instruction system and hardware structure. P89C51RD2 uses the original 16-bit addressing mechanism of external data and program memory, expands the on-chip RAM to 1K bytes, and expands the on-chip FLASH EPROM to 64K bytes. Since the internal code of a Chinese character occupies two bytes, 1024 bytes can store 512 Chinese characters, so 64KB flash memory can store more than 30,000 Chinese characters.
This system uses a LCD display model MTG-F24128CMNHSCW with CCFL backlight produced by Microtips Technology Inc. and built-in T6963C produced by Toshiba. The relevant interface information is as follows
The relevant pictures of this topic are as follows:
The relevant pictures of this topic are as follows:
Hardware design description
Since the capacity of AT29C020 is 256KB and the 80C51 series microcontroller can only manage 64KB of data space, the AT29C020 can be
divided into 8 pages, each page is 32KB, occupying 0000 7FFFH of the microcontroller system data space. The remaining 32KB space is for other memories and peripherals of the microcontroller system.
A15 is inverted as the LCD chip select LCD/CS P1.5 controls the LCD display to display positive and negative.
The reset level of this LCD is low, which is exactly the opposite of P89C51RD2 [page]
Four display principles and software programming
In the first section, we have concluded that the area code of the Chinese character is 195AH, which is converted to decimal 2590, that is, the dot matrix of the Chinese character is located
at the 90th word of the 25th area, which is equivalent to the position 32 [(25-1) 94 (90-1)] in the file HZK16. The 32 bytes after 75040B are the display dot matrix of the Chinese character.
In this system, A15 A17 of AT29C020 are connected to P1.0 P1.1 and P1.2 of P1 port respectively as page selection control A0
A14 is directly connected to A0 A14 of the microcontroller. Using the MOVX instruction to continuously fetch 32 bytes and send them to the corresponding position of the LCD can realize the correct display of Chinese characters.
Since the 240 128 dot LCD display can only display 15 Chinese characters per line, the sentences to be displayed can be written as 15 Chinese characters per line. Punctuation marks should be full-width. If there are less than 15 Chinese characters, spaces should be added. This is the content of MENG.ASM in the following software.
For the convenience of readers, the relevant programs that have been compiled are listed. For the specific use of LCD, please refer to the literature [2]
Main program
C_ADD EQU 8001H LCD command address
D_ADD EQU 8000H LCD data address
DAT1 EQU 30H
DAT2 EQU 31H
COM EQU 32H
CODE1 EQU 33H
COUNT EQU 34H
O_Y EQU 35H
O_X EQU 36H
COUNT_X EQU 37H
ORG 0000H
SJMP START
ORG 0030H
START: MOV SP, #60H
ORL AUXR, #02H EXTRAM bit 1 Access external data memory
ANL AUXR1, #0FH ENBOOT=0 Access to FLASH
CLR P1.5 Positive display
LCALL INT Initialization setting subroutine
LCALL CLEAR Clear screen
MOV DPTR, #TABLE The beginning of science fiction
MOV O_Y, #00H
PUSH DPH
PUSH DPL
LOOP: POP DPL
POP DPH
MOV R0, #0E0H Font data temporary storage area
MOV R7, #30 Each Chinese character is 2 bytes Each line of 15 Chinese characters requires 30 bytes
PRHZ3: CLR A
MOVC A, @A+DPTR
MOV @R0,A
INC R0
INC DPTR
DJNZ R7, PRHZ3
PUSH DPH
PUSH DPL
MOV O_X, #00H
MOV R0, #0E0H
MOV COUNT_X, #15
LCD112: MOV 24H, @R0 24H and 25H are temporary buffers
INC R0
MOV 25H, @R0
INC R0
MOV A, 24H
CLR C
SUBB A, #0A1H Convert to area code
MOV 24H, A
MOV A, 25H
CLR C
SUBB A, #0A1H
MOV 25H, A
MOV A, R0
PUSH ACC
LCALL DPONHZ Get font data and store into registers starting from 0C0H
LCALL WRI_CC Send for display
POP ACC
MOV R0, A
INC O_X
INC O_X
DJNZ COUNT_X,LCD112 Jump after sending 1 line of Chinese characters
MOV A, O_Y
ADD A, #10H
MOV O_Y, A
MOV A, O_Y
CJNE A, #80H, LOOP
MOV O_Y, #00H
LCALL DELAY After sending 1 screen, extend the time for easy reading
LCALL DELAY
LCALL DELAY
LCALL DELAY
LCALL DELAY
LCALL DELAY
POP DPL
POP DPH
PUSH DPH
PUSH DPL
MOV A, DPH
SUBB A, #0DFH Novel end address If it is the end, reset and restart
JNC RST1
JMP LOOP
RST1: MOV A, DPL
SUBB A, #2AH
JNC RST
JMP LOOP
RST: JMP START
DPONHZ: MOV A, 24H Get font data to the internal storage area starting at 0C0H
MOV B, #94
MUL AB
ADD A, 25H
MOV 25H, A
CLR A
ADDC A, B
MOV 24H, A
CLR C
RRC A
CLR C
RRC A
MOV P1, A
LCALL RL245
CLR 24H.7
MOV DPH, 24H
MOV DPL, 25H
MOV R2, #32
MOV R1, #0C0H
DPHZ2: MOVX A, @DPTR
INC DPTR
MOV @R1, A
INC R1
DJNZ R2, DPHZ2
RET
RL245: MOV R7, #05 24H25H Shift left 5 bits
RLL1: CLR C
MOV A, 25H
RLC A
MOV 25H,A
MOV A, 24H
RLC A
MOV 24H, A
DJNZ R7, RLL1
RET
R_ST: MOV DPTR, #C_ADD Read status
MOVX A, @DPTR
RET
ST01: LCALL R_ST Before reading or writing a data
JNB ACC.0, ST01
JNB ACC.1, ST01
RET
ST2: LCALL R_ST Before continuous reading
JNB ACC.2, ST2
RET
ST3: LCALL R_ST Before continuous writing
JNB ACC.3, ST3
RET
ST6: LCALL R_ST
JB ACC.6, ERR
RET
ERR: LJMP ST6
PR1: LCALL ST01
MOV A, DAT1
LCALL PR13
PR11: LCALL ST01
MOV A, DAT2
LCALL PR13
PR12: LCALL ST01
MOV A, COM
LJMP PR14
PR13: MOV DPTR, #D_ADD
PR14: MOVX @DPTR, A
RET
PR2: LCALL ST01
MOV DPTR, #D_ADD
MOVX A, @DPTR
MOV DAT2, A
RET
INT: MOV DAT1, #00H Initialization setting subroutine
MOV DAT2, #00H
MOV COM, #40H
LCALL PR1
MOV DAT1, #2 0H
MOV DAT2, #00H
MOV COM, #41H
LCALL PR1
MOV DAT1, #00H
MOV DAT2, #08H
MOV COM, #42H
LCALL PR1
MOV DAT1, #20H
MOV DAT2, #00H[page]
MOV COM, #43H
LCALL PR1
MOV COM, #0A7H
LCALL PR12
MOV COM, #80H
LCALL PR12
MOV COM, #9CH
LCALL PR12
RET
CLEAR: MOV DAT1, #00H Set the display memory first address
MOV DAT2, #00H
MOV COM, #24H
LCALL PR1
MOV R3, #00H Set the loop size to 8K bytes
MOV R4, #20H
MOV COM, #0B0H Set the automatic write mode
LCALL PR12
CLEAR1: LCALL ST3 Judge status bit S2
MOV A, #00H Set data to 0
LCALL PR13 Write data
DJNZ R3, CLEAR1 Loop
DJNZ R4, CLEAR1
MOV COM, #0B2H Set automatic write end instruction
LCALL PR12
RET
WRI_CC: PUSH O_X Send font data to display
PUSH O_Y
MOV A, O_Y
MOV B, #20H
MUL AB
ADD A, O_X
MOV O_X, A
MOV A, B
ADDC A, #08H
MOV O_Y, A
MOV R0, #0C0H
MOV COUNT, #10H
WRI_CC1:MOV DAT1, O_X
MOV DAT2, O_Y
MOV COM, #24H
LCALL PR1
MOV A, @R0
MOV DAT2,A
INC R0
MOV A, @R0
INC R0
MOV DAT1, A
MOV COM, #0C0H
LCALL PR11
MOV DAT2, DAT1
LCALL PR11
MOV A, #20H
ADD A, O_X
MOV O_X, A
CLR A
ADDC A, O_Y
MOV O_Y, A
DJNZ COUNT, WRI_CC1
POP O_Y
POP O_X
RET
DL1MS: MOV R4, #0C0H
DLY1: P
DJNZ R4,DLY1
RET
DL10MS: CALL DL1MS
CALL DL1MS
CALL DL1MS
CALL DL1MS
CALL DL1MS
CALL DL1MS
CALL DL1MS
CALL DL1MS
CALL DL1MS
CALL DL1MS
RET
DELAY: MOV R5,#0C8H ;Delay 1 second
DL5MS: MOV R4,#0FAH
DLY: NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP NOP
DJNZ R4,DLY
DJNZ R5,DL5MS
RET
INCLUDE \'MENG.ASM\'
END
The beginning of MENG.ASM is as follows. Since this science fiction novel is too long, only the beginning is listed. Each line has 15 Chinese characters. Punctuation marks
All symbols are in full-width
TABLE:
Chapter One: The Sage
of the Single Hero Bontau is the greatest
metropolis on earth and the oldest city on earth.
Since 3,250 years ago,
all nations on earth have developed from economic communities to politically
unified countries.
The federal government, the core of central power, was established in this unprecedented
magnificent metropolis.
The existence of Bontau represents
the disappearance of the old civilization. There are no more national boundaries, religions, and
ethnic groups. These factors that make the world's disputes endless
exist.
After a devastating war, the Federal Republic
gained new life like a phoenix after the ashes
. Under the strong rule of the federal government, this disaster
-stricken planet finally has unprecedented
long-term peace and stability
. In addition to Bontau, there are 48 large
cities. More than 2 billion people from the world live here
. \'Some cities are in and around the city and are
ruins due to nuclear contamination and\' DB \' cosmic ray attacks. According to the federal government\'
DB \' declared that they are no longer suitable for any life\'
DB \' reproduction. The most famous building in Bontouri\'
DB \' is where the heads of the federal government and ministers work\'
DB \'. The triangular building is a unique building\'
DB \'. It is the tallest building in the world and also
the top masterpiece of human\' DB \' architectural technology. The federal government\'
DB \' building decree explicitly stipulates that\'
DB \' buildings taller than her are not allowed, so that she will always bear\'
DB \' the greatest reputation\' DB
\'. People call her the pyramid\'
DB \'. She represents the birth of a great era\'
DB \' symbolizes that ancient wisdom has become the object of ridicule and mockery\'
DB \'. The era of the object reigning over the earth\'.
Just follow the format and enter all the contents. After the compilation is correct, write the generated BIN file into P89C51RD2 and ensure that the entire hardware
circuit is correct. Then, after power-on reset, please enjoy your science fiction novel.
References
[1] Xu Zhuonong, Zhang Yongzhong. Chinese character display in single chip microcomputer system. Single chip microcomputer and embedded system application. 2001(7):31-34
[2] Li Weiti, Guo Qiang. Liquid crystal display application technology. 1st edition. Beijing: Electronic Industry Press. 2000.3
[3] Wang Shiyuan. C advanced utility program design. 1st edition. Beijing Tsinghua University Press. 1996.6
[4] P89C51RX2 DATA SHEET. Philips Semiconductors. 2001.
[5] MTG-F24128CMNHSCW, LCD MODULE SPECIFICATION FOR CUSTOMER S APPROVAL. Microtips Technology
Inc. 1999.
Previous article:C language error information quick query
Next article:Using 16-bit MCU to implement home smart terminal design
Recommended ReadingLatest update time:2024-11-17 02:26
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- Severe packet loss when transmitting large amounts of data using TI's CC1310
- Hardware Implementation of Asynchronous FIFO Based on FPGA
- Microcontroller low power design resources
- Codec is the key to PMP
- Exclusively sell Lumentum's high-quality optical communication module packaging and testing equipment, don't miss this opportunity!
- The Electronic Engineer Self-Study Handbook is here! Read good books for free to help electronic engineers grow!
- How to ensure high performance design of PCB
- AD5064 drives 16-bit da
- I bought a ZT303 multimeter.
- Design techniques for machine learning algorithm generation (provided by ST official, Chinese subtitles)