Berita
Berita
Ringkasan sains populer terkuat MCU [koleksi rekomendasi] (3)
2022-03-17 230
12,Overview of Chinese characters:
Untuk menampilkan karakter Tionghoa pada monitor atau printer, karakter Tionghoa dirancang ke dalam matriks titik sesuai dengan simbol grafis, dan kode matriks titik (kode glif) yang sesuai diperoleh.  
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.  
  Kode dalam kamera  
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.  
Jika kita mengganti tanda "." pada grafik "口" ini dengan "0", kita dapat memperoleh kode glif dari "口" dengan sangat jelas: 0000H 0004H 3FFAH 2004H 2004H 2004H 2004H 2004H 2004H 2004H 2004H 3FFAH 2004H 0000H 0000H. Ketika komputer ingin menampilkan "口", pertama-tama ia menemukan alamat pertama dari pustaka font tampilan, menghitung berdasarkan kode internal "口", kemudian menemukan kode glif dari "口", dan kemudian memindai layar secara berurutan sesuai dengan kode glif (dalam biner) melalui kontrol generator karakter. Jika kode biner bernilai "0", tempat yang bernilai "0" akan dipindai, dan tempat yang bernilai "1" juga akan dipindai untuk disorot, sehingga pola karakter "口" dapat diperoleh.  
Font aksara Tionghoa disusun berdasarkan urutan kode standar nasional dan disimpan dalam memori dalam bentuk file biner, membentuk pustaka font aksara Tionghoa, yang juga disebut pustaka glif aksara Tionghoa, atau pustaka aksara Tionghoa.
Dua metode pengkodean, lihat file header.
    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;


    codeGB_16[k].Index[0] codeGB_16[k] menunjukkan bahwa ada array struktur typFNT_GB16 yang disebut codeGB_16 codeGB_16[k] adalah anggota ke-k+1 dari array index adalah anggota struktur typFNT_GB16, sehingga dapat dirujuk dengan codeGB_16[k].Index. Pada saat yang sama, index adalah array, sehingga dapat diindeks[0] Jika((codeGB_16[k].Index[0]==c[0])&&(codeGB_16[k].Index[1]==c[1])) && adalah operator logika AND, yang berarti bahwa nilai di kedua sisi simbol && adalah benar. Hanya nilai && yang benar, yaitu, benar && benar = benar. Kalimat ini berarti: codeGB_16[k].Index[0]==c[0] dan codeGB_16[k].Index[1]==c[1] ditetapkan pada saat yang bersamaan. Jika pernyataan berikut dieksekusi, codeGB_16[] adalah array struktur, codeGB_16[k].Index[0] berarti nilai elemen ke-0 dari anggota indeks struktur ke-K dari array struktur.    

    13,12864 LCD:

    Setiap titik tampilan sesuai dengan angka biner, 1 berarti menyala, 0 berarti mati. RAM yang menyimpan informasi matriks titik ini disebut memori data tampilan. Untuk menampilkan grafik atau karakter Cina tertentu, informasi matriks titik yang sesuai harus ditulis ke dalam unit penyimpanan yang sesuai.


    Penghitung alamat (AC) pada RAM grafis hanya akan secara otomatis menaikkan alamat horizontal (sumbu X) sebesar satu. Ketika alamat horizontal = 0FH, maka akan direset menjadi 00H. Namun, ia tidak akan secara otomatis menaikkan alamat vertikal dengan carry. Oleh karena itu, ketika beberapa data ditulis secara terus menerus, program perlu menentukan apakah alamat vertikal perlu direset.


      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

      ①. Bagaimana alokasi memori variabel dilakukan dalam bahasa C mikrokontroler? Mungkinkah kompiler secara cerdas menambahkan kode alokasi dan daur ulang selama proses kompilasi? Poin kuncinya adalah, bagaimana saya dapat memastikan program yang saya buat tidak mengalami kesalahan kelebihan memori (memory overflow)? Jika saya melakukan operasi rekursif, maka kebutuhan memori sulit dihitung sendiri.  
      ②. Apakah bahasa C mikrokontroler akan terbatas dalam definisi variabel? Misalnya, operasi perkalian dan pembagian data floating-point ditulis melalui bahasa assembly, dan kodenya cukup rumit. Jika ditulis langsung dalam bahasa C, bukankah akan terlalu sederhana?  
      ③. Dalam file hex yang dihasilkan oleh bahasa C pada mikrokontroler, apakah distribusi alamat ROM instruksi dan data ditetapkan secara otomatis oleh kompiler? Dapatkah pengguna menetapkannya sendiri?  
      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.  
      Jika terlalu banyak variabel, kompiler akan memberi peringatan bahwa segmen data terlalu besar. Untuk memastikan tidak terjadi kesalahan kelebihan memori (memory overflow), pertimbangan utama adalah apakah terjadi kelebihan tumpukan (stack overflow), dan hal ini bergantung pada pengalaman.
      Bahasa C pada mikrokontroler umumnya melarang rekursi, dan operasi rekursif umumnya dihindari. Bagaimanapun, mikrokontroler bukanlah PC, yang akan memengaruhi kecepatan. Jika Anda ingin melakukan rekursi, lebih tepat menggunakan chip DSP. Singkatnya, Anda harus mampu memilih chip yang tepat.
      Jawaban 2: Ukuran variabel (jumlah digit) umumnya sama dengan jumlah digit pada akumulator chip. Misalnya, 51 biasanya menggunakan 8 bit karena merupakan mikrokontroler 8-bit.

      Mikrokontroler dapat mendefinisikan variabel bit, tetapi tidak dapat mendefinisikan array bit. Menulis dalam bahasa C tampak sederhana, tetapi sebenarnya menghasilkan jumlah kode terbesar. Mikrokontroler yang digunakan untuk kontrol hampir tidak menggunakan operasi floating point, yang tidak hanya lambat tetapi juga merepotkan dan memakan ruang. Jika itu adalah chip DSP, akan jauh lebih baik jika memiliki struktur perangkat keras yang sesuai.  
       

      Jawaban 3: Umumnya, alokasi dilakukan secara otomatis. Pemrograman dapat dilakukan dengan kombinasi bahasa C dan bahasa assembly, atau dapat dirakit secara online menggunakan Keil C. Pertukaran data antara chip dan perangkat luar dilakukan melalui port.


      Penafian: Artikel ini direproduksi dari "International Electronic Business Information". Artikel ini hanya mewakili pandangan pribadi penulis dan tidak mewakili pandangan Sacco Micro dan industri. Artikel ini hanya untuk dicetak ulang dan dibagikan serta mendukung perlindungan hak kekayaan intelektual. Harap sebutkan sumber asli dan penulis untuk pencetakan ulang. Jika ada pelanggaran, silakan hubungi kami untuk menghapusnya.

      Nomor telepon perusahaan: +86-0755-83044319
      Faks/FAX: +86-0755-83975897
      Surel: 1615456225@qq.com
      QQ: 3518641314 Manajer Li

      QQ: 332496225 Manajer Qiu

      Alamat: Ruang 809, Gedung C, Gedung Teknologi Zhantao, No. 1079 Jalan Minzhi, Distrik Baru Longhua, Shenzhen

      whatsapp

      Hotline Layanan

      tel: +86 755 83044319

      WhatsApp

      Whatsapp:+8618073002950