好文档 - 专业文书写作范文服务资料分享网站

LCD1602汉字显示讲解

天下 分享 时间: 加入收藏 我要投稿 点赞

responsible for the development of company management, including the development of settlement and settlement standards of preparation, the business unit clearing work inspection and guidance, business settlement audit; 23, is in charge of the company business and costs calculation and nalysis of new projects and to develop standards and provide the basis for decision-making and responsible for the comprehensive economic and technical indicators and statistics, analysis, summary and reporting; 24, the company responsible for audits of various types of business contracts, the principal of contract price (purchase price, freight, taxes, etc), payment method, payment, settlement, such as the reasonableness of the data, authenticity, accuracy; 25, strict enforcement of national tax policy, is responsible for the monthly reporting, including tax calculations, statistics, go through the relevant formalities, receive invoices; 26, the company responsible for all kinds of price (including product price, material prices,Freight, engineering machinery jobs price, price, price) 's terms of market surveys, quotations, price exception report; 27, is responsible for the company's management, including conference organized by price, of historical prices, totals, etc; 28, according to the annual operating plan, annual costs and undergo decomposition, control, analysis and evaluation; responsible for costing and cost control, ensure accounting number is reasonable, correct, and complete accounting report and the company's other reports compiled and reported to work;LCD1602显示汉字研究与程序设计

1602是一款最常用也是最便宜的液晶显示屏。最多可以显示两行标准字符,每行最多可以显示16个字符。

1602可以显示内部常用字符(包括阿拉伯数字,英文字母大小写,常用符号和日文假名等),也可以显示自定义字符(单或多个字符组成的简单汉字,符号,图案等,最多可以产生8个自定义字符)。

一、显示常用字符。

1602液晶模块内部的字符发生存储器(CGROM)已经存储了160个不同的点阵字符图形,如下表所示,这些字符有:阿拉伯数字、英文字母的大小写、常用的符号、和日文假名等,每一个字符都有一个固定的代码,比如大写的英文字母“A”的代码是41H,显示时模块把地址41H中的点阵字符图形显示出来,我们就能看到字母“A”

十进制 十六进制 ASCII字符 十进制 十六进制 ASCII 字符 十进制 十六进制 ASCII字符

00 00 自定义字符1 56 38 8 96 60 ` 01 01 自定义字符2 57 39 9 97 61 a 02 02 自定义字符3 58 3A : 98 62 b 03 03 自定义字符4 59 3B ; 99 63 c 04 04 自定义字符5 60 3C < 100 64 d 05 05 自定义字符6 61 3D = 101 65 e 06 06 自定义字符7 62 3E > 102 66 f 07 07 自定义字符8 63 3F ? 103 67 g 08 08 自定义字符1 64 40 @ 104 68 h 09 09 自定义字符2 65 41 A 105 69 i 10 0A 自定义字符3 66 42 B 106 6A j 11 0B 自定义字符4 67 43 C 107 6B k 12 0C 自定义字符5 68 44 D 108 6C l 13 0D 自定义字符6 69 45 E 109 6D m 14 0E 自定义字符7 70 46 F 110 6E n 15 0F 自定义字符8 71 47 G 111 6F o 32 20 空格 72 48 H 112 70 p 33 21 ! 73 49 I 113 71 q 34 22 \ 74 4A J 114 72 r 35 23 # 75 4B K 115 73 s 36 24 $ 76 4C L 116 74 t 37 25 % 77 4D M 117 75 u 38 26 & 78 4E N 118 76 v 39 27 ' 79 4F O 119 77 w 40 28 ( 80 50 P 120 78 x 41 29 ) 81 51 Q 121 79 y 42 2A * 82 52 R 122 7A z 43 2B + 83 53 S 123 7B { 44 2C , 84 54 T 124 7C | 45 2D - 85 55 U 125 7D }

responsible for the development of company management, including the development of settlement and settlement standards of preparation, the business unit clearing work inspection and guidance, business settlement audit; 23, is in charge of the company business and costs calculation and nalysis of new projects and to develop standards and provide the basis for decision-making and responsible for the comprehensive economic and technical indicators and statistics, analysis, summary and reporting; 24, the company responsible for audits of various types of business contracts, the principal of contract price (purchase price, freight, taxes, etc), payment method, payment, settlement, such as the reasonableness of the data, authenticity, accuracy; 25, strict enforcement of national tax policy, is responsible for the monthly reporting, including tax calculations, statistics, go through the relevant formalities, receive invoices; 26, the company responsible for all kinds of price (including product price, material prices,Freight, engineering machinery jobs price, price, price) 's terms of market surveys, quotations, price exception report; 27, is responsible for the company's management, including conference organized by price, of historical prices, totals, etc; 28, according to the annual operating plan, annual costs and undergo decomposition, control, analysis and evaluation; responsible for costing and cost control, ensure accounting number is reasonable, correct, and complete accounting report and the company's other reports compiled and reported to work;46 2E . 86 56 V 126 7E ~ 47 2F / 87 57 W 48 30 0 88 58 X 49 31 1 89 59 Y 50 32 2 90 5A Z 51 33 3 91 5B [ 52 34 4 92 5C \\ 53 35 5 93 5D ] 54 36 6 94 5E ^ 55 37 7 95 5F _

显示操作的过程:

首先确认显示的位置,即在第几行,第几个字符开始显示。也就是要显示的地址,如下表所示的显示地址。

第一行的显示地址是0x80-0x8F,第二行的显示地址是0xC0-0xCF。例如想要在第2行,第3个位置显示一个字符,那么地址码就是 0xC2。在编程过程中,通常编写一个函数确定在某行某个位置显示数据。函数需要 行参数(y),和 列参数(x)来确定显示位置。程序参考如下

/***************设置显示位置**************************/ void LCD_set_xy( unsigned char x, unsigned char y ) {

unsigned char address;

if (0 == y) x |= 0x80; //当要显示第一行时地址码+0x80; else x |= 0xC0; //在第二行显示是地址码+0xC0;

Write_com(x); //发送地址码 0x80-0x8F 或者0xC0-0xCF

} 以上地址码,在显示过程中,可以直接应用,至于地址码的计算原理,如果想要研究,请参考其它资料,这里不做描述。

其次设置要显示的内容,即上面提到的CGROM内的字符编码。如显示“A”,将编码41H写入到液晶屏显示即可。通常设置地址和显示内容用一个函数来完成。代码参考如下:

responsible for the development of company management, including the development of settlement and settlement standards of preparation, the business unit clearing work inspection and guidance, business settlement audit; 23, is in charge of the company business and costs calculation and nalysis of new projects and to develop standards and provide the basis for decision-making and responsible for the comprehensive economic and technical indicators and statistics, analysis, summary and reporting; 24, the company responsible for audits of various types of business contracts, the principal of contract price (purchase price, freight, taxes, etc), payment method, payment, settlement, such as the reasonableness of the data, authenticity, accuracy; 25, strict enforcement of national tax policy, is responsible for the monthly reporting, including tax calculations, statistics, go through the relevant formalities, receive invoices; 26, the company responsible for all kinds of price (including product price, material prices,Freight, engineering machinery jobs price, price, price) 's terms of market surveys, quotations, price exception report; 27, is responsible for the company's management, including conference organized by price, of historical prices, totals, etc; 28, according to the annual operating plan, annual costs and undergo decomposition, control, analysis and evaluation; responsible for costing and cost control, ensure accounting number is reasonable, correct, and complete accounting report and the company's other reports compiled and reported to work;//功能:按指定位置显示一个字符

//输入:列显示地址x(取值范围0-15) 行显示地址y(取值范围0-1), 指定字符 void DisplayOneChar(unsigned char x, unsigned char y, unsigned char Data) {

if (0 == y) x |= 0x80; //当要显示第一行时地址码+0x80; else x |= 0xC0; //在第二行显示是地址码+0xC0; Write_com(x); //发送地址码

Write_dat(Data); //发送要显示的字符编码 }

显示字符“A”调用过程如下代码: DisplayOneChar(0,0,0x41);//功能:在第1行 第1个字符 显示一个大写字母A

在C语言操作时,还可以显示整个字符串。定义一个字符串显示函数,可以通过直接输入字符方式进行显示

//功能:按指定位置显示一串字符

//输入:列显示地址x(取值范围0-15) 行显示地址y(取值范围0-1), 指定字符串指针*p,要显示的字符个数count (取值范围1-16)

void Disp_1602(unsigned char x,unsigned char y,unsigned char *p,unsigned char count) {

unsigned char i; for(i=0;i

if (0 == y) x |= 0x80; //当要显示第一行时地址码+0x80; else x |= 0xC0; //在第二行显示是地址码+0xC0; Write_com(x); //发送地址码

Write_dat(*p); //发送要显示的字符编码 x++; p++; } }

调用方法如下:

DisplayListChar(0,0,\液晶1602第一行显示

DisplayListChar(0,1,\www.qm999.cn\); //液晶1602第二行显示

二、显示自定义字符。

1、首先取得想要的中文或者图形的字模数组。通过字模软件不能直接提取5*8点阵的字模数据,可以通过手动提取的方法。如下图所示,对应一个字符显示区域。每8个字节,组成一个点阵数组。

responsible for the development of company management, including the development of settlement and settlement standards of preparation, the business unit clearing work inspection and guidance, business settlement audit; 23, is in charge of the company business and costs calculation and nalysis of new projects and to develop standards and provide the basis for decision-making and responsible for the comprehensive economic and technical indicators and statistics, analysis, summary and reporting; 24, the company responsible for audits of various types of business contracts, the principal of contract price (purchase price, freight, taxes, etc), payment method, payment, settlement, such as the reasonableness of the data, authenticity, accuracy; 25, strict enforcement of national tax policy, is responsible for the monthly reporting, including tax calculations, statistics, go through the relevant formalities, receive invoices; 26, the company responsible for all kinds of price (including product price, material prices,Freight, engineering machinery jobs price, price, price) 's terms of market surveys, quotations, price exception report; 27, is responsible for the company's management, including conference organized by price, of historical prices, totals, etc; 28, according to the annual operating plan, annual costs and undergo decomposition, control, analysis and evaluation; responsible for costing and cost control, ensure accounting number is reasonable, correct, and complete accounting report and the company's other reports compiled and reported to work;

“日”的点阵数组即为 {0x1f,0x11,0x11,0x1f,0x11,0x11,0x1f,0x00} 2个点阵组成一个汉字取模举例:

“车”字取模数组为:{0x00,0x0f,0x02,0x04,0x07,0x00,0x0f,0x00,

0x10,0x1e,0x00,0x10,0x1c,0x10,0x1e,0x10}

将生成的点阵数组保存到CGRAM存储器中,生成自定义字符。1602内部CGRAM用于自定义的字符点阵的存储,总共64字节。由上一步点阵提取可知,每一个字符由8个字节数据组成。所以64字节CGRAM存储器,能够存储8组自定义字符的点阵数组。按照CGRAM地址划分为 0-7为第一组,8-15为第二组,依次类推56-63为第8组数据。把自定义字符的数组按8个字节一组存储到CGRAM中,程序代码参考如下。 //功能:将自定义字符的编码数组 写入到CGRAM中. //输入:自定义字符的编码数组

void Write_CGRAM(unsigned char *p) {

unsigned char i,j,kk;

unsigned char tmp=0x40; //操作CGRAM的命令码 kk=0;

for(j=0;j<8;j++) //64 字节存储空间,可以生成 8 个自定义字符点阵 {

for(i=0;i<8;i++) // 8 个字节生成 1 个字符点阵 {

Write_com(tmp+i); //操作CGRAM的命令码+写入CGRAM地址. Write_dat(p[kk]); //写入数据

responsible for the development of company management, including the development of settlement and settlement standards of preparation, the business unit clearing work inspection and guidance, business settlement audit; 23, is in charge of the company business and costs calculation and nalysis of new projects and to develop standards and provide the basis for decision-making and responsible for the comprehensive economic and technical indicators and statistics, analysis, summary and reporting; 24, the company responsible for audits of various types of business contracts, the principal of contract price (purchase price, freight, taxes, etc), payment method, payment, settlement, such as the reasonableness of the data, authenticity, accuracy; 25, strict enforcement of national tax policy, is responsible for the monthly reporting, including tax calculations, statistics, go through the relevant formalities, receive invoices; 26, the company responsible for all kinds of price (including product price, material prices,Freight, engineering machinery jobs price, price, price) 's terms of market surveys, quotations, price exception report; 27, is responsible for the company's management, including conference organized by price, of historical prices, totals, etc; 28, according to the annual operating plan, annual costs and undergo decomposition, control, analysis and evaluation; responsible for costing and cost control, ensure accounting number is reasonable, correct, and complete accounting report and the company's other reports compiled and reported to work; kk++; }

tmp += 8; }

} 上一步中,自定义字符存储到CGRAM的任意一组以后,每一个组(8个字节)也有一个显示编码。按顺序依次为00H-07H 。显示时,只要调用每一组的编码,即可以显示相应的字符。

注:内部常用字符显示时,显示编码是从0x20开始的。0x00-0x0f是专门留给自定义字符显示的。0x00-0x07和0x08-0x0f内容是一样的。例如:调用0x01 位置和0x09位置,显示的内容是一样的。

直接按照单个字符的显示方式调用显示函数,就可以显示自定义字符了。代码参考如下: //在第1行,第7个位置显示自定义汉字 “年”

DisplayOneChar(6,0,0); //显示 \年\码 00

说明:此时“年”的8个字节点阵数组 ,存储空间为CGRAM的 00-07地址

也就是CGRAM的第1组数据存储区域,编码为0。 如果存储在CGRAM的08-15地址,那么编码就应该是 1了。

很多资料中,都没有详细介绍过CGRAM和CGROM的区别和用法,在1602调试过程中经常会被搞混。这里总结一点小技巧,希望能给需要的人一点帮助。 以下是显示效果: 常用字符显示:

LCD1602汉字显示讲解

responsibleforthedevelopmentofcompanymanagement,includingthedevelopmentofsettlementandsettlementstandardsofpreparation,thebusinessunitclearingworkinspectionandguidance,busi
推荐度:
点击下载文档文档为doc格式
0l9046aelc8njyy26yqz6tzp834d3b018rp
领取福利

微信扫码领取福利

微信扫码分享