Service Hotline
In order to output Chinese characters on a monitor or printer, the Chinese characters are designed into a dot matrix according to graphic symbols, and the corresponding dot matrix code (glyph code) is obtained.
The unified encoding method used to represent Chinese characters in computers is called internal code (such as national standard code), and the internal code is unique (equivalent to the ID number of the character). The Chinese character encoding formed to facilitate the input of Chinese characters is an input code, which is an external code of Chinese characters. The input code is different due to different encoding methods and is diverse. The Chinese character code formed for displaying and printing out Chinese characters is a glyph code. The computer finds the glyph code of the Chinese character in the font model library through the Chinese character internal code and realizes its conversion.
In-camera code
According to the provisions of the national standard code, each Chinese character has a certain binary code, but this code will conflict with the ASCII code when processed internally by the computer. To solve this problem, add 1 to the first byte of each byte of the national standard code. Since the ASCII code only uses 7 bits, the "1" in the first place can be used as a mark to identify Chinese character codes. When the computer processes the code with "1" in the first place, it understands it as Chinese character information, and when it processes the code with "0" in the first place, it understands it as an ASCII code. The national standard code (internal code) processed in this way is the internal code.
If we replace the "." of this "口" graphic with "0", we can get the glyph code of "口" very vividly: 0000H 0004H 3FFAH 2004H 2004H 2004H 2004H 2004H 2004H 2004H 2004H2004H 3FFAH 2004H 0000H 0000H. When the computer wants to output "口", it first finds the first address of the display font library, calculates based on the internal code of "口", and then finds the glyph code of "口", and then scans the screen sequentially according to the glyph code (in binary) through the control of the character generator. Where the binary code is "0", the place where it is "0" is scanned, and the place where it is "1" is scanned to highlight, so the character pattern of "口" can be obtained.
Chinese character fonts are arranged in the order of the national standard code and stored in the memory in the form of binary files, forming a Chinese character font library, also called a Chinese character glyph library, or a Chinese character library.
Two encoding methods, see header file
GB1616.h//------------------ Data structure definition of Chinese character font ------------------------//struct typFNT_GB16 //Chinese character font data structure { unsignedchar Index[3]; //Chinese character internal code index unsignedchar Msk[32]; //Dot matrix code data }; ///////////////////////////////////////////////////////////////////////////// Chinese character font table //// Chinese character library: Song style 16.dot, horizontal modulo left high bit, data arrangement: left to right, top to bottom ///////////////////////////////////////////////////////////////////////////// conststruct typFNT_GB16 codeGB_16[]= //Data table {/*------------------------------------------------------------------------------------------------ Source file/text: Xu; Width×Height (pixels):16×16---------------------------------------------------------------------------------*/ "Xu",0x10,0x80,0x10,0x80,0x21,0x40,0x42,0x20,0x94,0x10,0x1B,0xEC,0x20,0x80,0x60,0x8 0,0xAF,0xF8,0x20,0x80,0x22,0xA0,0x24,0x90,0x2A,0x88,0x21,0x00,0x00,0x00,0x00,0x00,
This structure is very simple:One is the internal code, a dot matrix sequence. The previous dot matrix library was placed in the order of the internal code, and no internal code index was needed. If only some Chinese characters were placed, the internal code index was needed. (The Chinese character "Xu" in the front is to find the dot matrix sequence of the word when outputting "Xu". This dot matrix sequence is written by myself. When displayed with 1602, because the chip has an English dot matrix sequence in the memory, there is no need to write it.) Generally, two bytes are enough for the internal code. If you use one more byte, you just add a trailing 0. In this way, the Chinese character string can be directly placed in the Chinese character internal code;
13、12864 LCD:
Each display point corresponds to a binary number, 1 means on, 0 means off. The RAM that stores these dot matrix information is called display data memory. To display a certain graphic or Chinese character is to write the corresponding dot matrix information into the corresponding storage unit.
The address counter (AC) of the graphics RAM will only automatically increment the horizontal address (X axis) by one. When the horizontal address = 0FH, it will be reset to 00H. However, it will not automatically increment the vertical address with a carry. Therefore, when multiple data are written continuously, the program needs to determine whether the vertical address needs to be reset.
14、Graphics RAM (GDRAM)
The drawing display RAM provides 128×8 bytes of memory space. When changing the drawing RAM, first write the horizontal and vertical coordinate values continuously, and then write two bytes of data to the drawing RAM. The address counter (AC) will automatically increase the horizontal address (X address) by one. When the horizontal address is 0XFH, it will be reset to 00H; the vertical address will not be automatically incremented by 1. The drawing display must be turned off during writing to drawing RAM.
[cpp] view plain copy//Display Chinese characters voiddispString (uchar X, Y,uchar *msg) //Which row is X and which column is Y. msg is Chinese characters { if(X==0) X = 0x80; // First line, Chinese characters display coordinates else if(X==1) write_data(*msg++); //Display Chinese characters } } ////////////////////////////////// //////////////// //////////////// // Display image voiddisppicture(uchar code *adder) { uint i,j; //*******Display the upper half screen content setting for(i=0;i<32;i++) // 32 column addresses in the upper half of the screen { write_com(0x80 + i); //SET vertical address VERTICALADD write_com(0x80); //SET horizontal address HORIZONTAL ADD for(j=0;j<16;j++) { write_data(*adder); adder++; } } //************Display the content settings of the lower half of the screen for(i=0;i<32;i++) // { write_com(0x80 + i); //SET vertical address VERTICALADD write_com(0x88); //SET horizontal address HORIZONTAL ADD for(j=0;j<16;j++) { write_data(*adder); adder++; } } } For the C language, space is automatically allocated for a defined variable, and its address is the name of the variable. Through this name, the data can be retrieved in the memory and new data can be obtained through calculation. However, in assembly, the programmer needs to define the storage space and send the data to the accumulator for calculation. Every step requires the programmer's operation. In C language, these processes are completed by the compiler.
15、Some useful FAQs
①. How is the memory allocation of variables carried out in microcontroller C language? Could it be that the compiler intelligently adds allocation and recycling code during the compilation process? The key point is that the program I made, how can I ensure that it does not have memory overflow errors? If I'm doing a recursive operation, then the memory requirements are difficult to calculate by myself.
②. Will the microcontroller C language be restricted in variable definition? For example, the multiplication and division operations of floating-point data are written through assembly, and the code is quite complicated. If written directly in C language, wouldn't it be too simple?
③. In the hex file generated by the C language of the microcontroller, is the address distribution of the instruction and data ROM automatically assigned by the compiler? Can users assign it?
Answer 1: The microcontroller program written in C language is first compiled by a program (it seems to be c51.exe). After the compilation is completed, the storage space size of the variables has been arranged, but the specific address has not yet been allocated (the address is floating). Next, another program (it seems to be a51.exe) is connected. After the connection, the specific address is determined.
If there are too many variables, the compiler will prompt that the data segment is too large. To ensure that there is no memory overflow error, the main consideration is whether the stack overflows, and it depends on experience.
The C language of microcontrollers generally prohibits recursion, and recursive operations are generally avoided. After all, microcontrollers are not PCs, which will affect the speed. If you want to recurse, it is more appropriate to use a DSP chip. In short, you must be able to choose the appropriate chip.
Answer 2: The size of the variable (number of digits) is generally the same as the number of digits in the chip accumulator. For example, 51 commonly uses 8 bits because it is an 8-bit microcontroller.
The microcontroller can define bit variables, but it cannot define bit arrays. Writing in C language seems simple, but actually generates the largest amount of code. The microcontroller used for control hardly uses floating point operations, which is not only slow but troublesome and takes up space. If it is a DSP chip, it will be much better if it has a suitable hardware structure.
Answer 3: Generally, it is automatically allocated. It can be programmed in a mixture of C language and assembly language, or it can be assembled online using Keil C. The data exchange between the chip and the outside is done through the port.
Disclaimer: This article is reproduced from "International Electronic Business Information". This article only represents the author's personal views and does not represent the views of Sacco Micro and the industry. It is only for reprinting and sharing and supports the protection of intellectual property rights. Please indicate the original source and author for reprinting. If there is any infringement, please contact us to delete it.
Company phone number: +86-0755-83044319
Fax/FAX: +86-0755-83975897
Email: 1615456225@qq.com
QQ: 3518641314 Manager Li
QQ: 332496225 Manager Qiu
Address: Room 809, Building C, Zhantao Technology Building, No. 1079 Minzhi Avenue, Longhua New District, Shenzhen




粤公网安备44030002007346号