25204|13

37

帖子

0

TA的资源

纯净的硅(初级)

楼主
 

12864液晶资料显示程序 [复制链接]

  1. 硬件连接方式是:并口直接访问。

  2. 这是汉字显示程序:

  3. #include
  4. #include

  5. #define uchar unsigned char

  6. #define datawr 0x1200           //写数据通道
  7. #define comwr 0x1000            //写控制命令通道
  8. #define datare 0x1300           //读数据通道
  9. #define comre 0x1100            //读忙通道

  10. uchar code disp_data[]={"    浙江大学    "      //第一行,第一页
  11.                         "04级通信工程一班"      //第三行
  12.                         " 宁波理工学院 "      //第二行
  13.                         "    竞赛小组    "      //第四行
  14.                         "128X64液晶显示器"      //第一行,第二页
  15.                         "    测试程序    "      //第三行
  16.                         " 07年07月25日 "      //第二行
  17.                         "    Tornado     "};    //第四行

  18. void set12864();
  19. void write_command(uchar command);
  20. void write_page(uchar data_add);
  21. void read_page(uchar data_add);
  22. void delays(uchar cont);

  23. void main()
  24. {
  25.     while(1)
  26.     {
  27.         set12864();             //初始化12864
  28.         write_page(0);          //写入一页数据
  29.         read_page(0x30);        //读出一页数据到内部RAM
  30.         delays(2);              //延时2s
  31.         write_page(64);         //写入下一页数据
  32.         delays(2);              //延时2s
  33.     }
  34. }

  35. //初始化12864子程序
  36. void set12864()
  37. {
  38.     write_command(0x30);        //功能设定控制字
  39.     write_command(0x0c);        //显示开关控制字
  40.     write_command(0x01);        //清除屏幕控制字
  41.     write_command(0x06);        //进入设定点控制字
  42. }

  43. //写控制命令子程序
  44. void write_command(uchar command)
  45. {
  46.     bit flag=1;                 //12864空闲标志位
  47.     while(flag)                 //检查12864是否空闲
  48.         flag="XBYTE"[comre]&0x80;
  49.     XBYTE[comwr]=command;       //空闲传送控制字
  50. }

  51. //写一页子程序
  52. void write_page(uchar data_add)
  53. {
  54.     bit flag=1;                //12864空闲标志位
  55.     uchar num=64;               //64个循环,连续写入32个汉字或是64个西文字符
  56.     write_command(0x80);
  57.     for(;num>0;num--)
  58.     {
  59.         while(flag)             //检查12864是否空闲
  60.             flag="XBYTE"[comre]&0x80;
  61.         XBYTE[datawr]=disp_data[data_add++]; //空闲传送数据
  62.     }
  63. }

  64. //读一页子程序
  65. void read_page(uchar data_add)
  66. {
  67.     bit flag=1;                 //12864空闲标志位
  68.     uchar num=64;               //64个循环,连续写入32个汉字或是64个西文字符
  69.     write_command(0x80);
  70.     for(;num>0;num--)
  71.     {
  72.         while(flag)             //检查12864是否空闲
  73.             flag="XBYTE"[comre]&0x80;
  74.         DBYTE[data_add++]=XBYTE[datare]; //空闲传送数据
  75.     }
  76. }

  77. //延时cont秒子程序
  78. void delays(uchar count)
  79. {
  80.     unsigned char h,i,j,k;
  81.     do
  82.     {
  83.     for(h=5;h>0;h--)
  84.     for(i=4;i>0;i--)
  85.     for(j=116;j>0;j--)
  86.     for(k=214;k>0;k--);
  87.     }while(--count);
  88. }

  89. 这是图象显示程序:

  90. #include
  91. #include

  92. #define uchar unsigned char
  93. #define uint unsigned int

  94. #define datawr 0x1200           //写数据通道
  95. #define comwr 0x1000            //写控制命令通道
  96. #define datare 0x1300           //读数据通道
  97. #define comre 0x1100            //读忙通道

  98. uchar code disp_data[] =        // 数据表
  99. {
  100.       0x00,0x01,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,
  101.       0x00,0x01,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,
  102.       0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,
  103.       0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,
  104.       0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,
  105.       0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,
  106.       0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,
  107.       0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x80,0x00,0x00,0x00,
  108.       0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  109.       0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  110.       0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0xFF,0xFF,0xFF,
  111.       0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x07,0xFF,0xFF,
  112.       0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x0B,0xFF,
  113.       0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x1F,
  114.       0x01,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,
  115.       0x01,0xFF,0xFF,0xFF,0xF3,0x79,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,
  116.       0x03,0xFF,0xFF,0xFF,0xE6,0x62,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE1,0x60,0x00,0x68,
  117.       0x01,0xFF,0xFF,0xFE,0x00,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE1,0x00,0x00,0x0E,
  118.       0x01,0xFF,0xFF,0xF8,0x00,0x4B,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x8E,0x08,0x79,
  119.       0x07,0xFF,0xFF,0xF0,0x00,0x41,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE6,0xC0,0x07,0x61,
  120.       0xC3,0xFF,0xFE,0xC0,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xED,0xEF,0x3F,
  121.       0x83,0xFF,0xFE,0x60,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  122.       0xC0,0xFF,0xFD,0xFC,0x6C,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  123.       0xF0,0x7F,0xF3,0xFF,0xFE,0x60,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  124.       0xFF,0xFF,0xF3,0xFF,0xFF,0x50,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,
  125.       0xFB,0xFF,0xF1,0xF8,0x8C,0xD8,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFB,0x6F,0xD9,
  126.       0xC2,0x3F,0xF8,0x40,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xF6,0xDF,0x1E,0xFF,
  127.       0xFF,0x7F,0xFC,0x38,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x64,0x2F,0x6F,0xFF,
  128.       0xFD,0x7B,0xFC,0x1F,0xE0,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x5F,0x7C,0xEE,0xFF,
  129.       0xC7,0xFF,0xBC,0x0F,0xFF,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xDF,0xFE,0xEF,0xFF,
  130.       0xFF,0xE7,0xDC,0x07,0xE7,0xF8,0x12,0x7F,0xFF,0xFF,0xFF,0xFF,0x47,0xFF,0xFF,0xFF,
  131.       0xFF,0xE7,0x80,0x03,0xF4,0x00,0x00,0x5F,0xFF,0xFF,0xFE,0xFE,0xE3,0xFF,0xFF,0xFF,
  132.       0xFF,0xFE,0xC0,0x01,0xC0,0x00,0x00,0x1B,0xFF,0xFF,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,
  133.       0x7F,0xEE,0xC0,0x00,0xC0,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  134.       0xFE,0x98,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xEF,0xFF,0xFF,0xFF,0xFF,0xFF,
  135.       0x20,0x0E,0x60,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,
  136.       0x05,0x80,0xE0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  137.       0x09,0x80,0xA0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,
  138.       0x85,0x2A,0xC0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
  139.       0xBF,0xF3,0xC0,0x00,0x00,0x00,0x00,0x00,0xFF,0xF7,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,
  140.       0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
  141.       0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0xFF,0xC0,0xFF,0xFF,0xFF,0xFF,0xC0,0x1F,
  142.       0xFF,0xFF,0x80,0x00,0x40,0x00,0x00,0x00,0xFF,0x80,0xFF,0xFF,0xFF,0x80,0x07,0xFF,
  143.       0xFF,0xFF,0xC0,0x00,0xC0,0x00,0x00,0x01,0xFF,0x01,0xFF,0xFF,0xF8,0x00,0xFF,0xFF,
  144.       0xFF,0xFF,0xE0,0x63,0x80,0x00,0x00,0x01,0xFE,0x01,0xFF,0x18,0x00,0x3F,0xFF,0xFF,
  145.       0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x01,0xCC,0x01,0xFE,0x00,0x07,0xFF,0xFF,0xFF,
  146.       0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x07,0xA0,0x03,0xFC,0x00,0xFF,0xFF,0xFF,0xFF,
  147.       0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x05,0xC0,0x03,0xC8,0x00,0x7F,0xFF,0xFF,0xFF,
  148.       0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x88,0x0C,0x07,0xFF,0xFF,0xFF,
  149.       0xFF,0xFF,0xFC,0x00,0x0C,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0xC0,0x7F,0xFF,0xFF,
  150.       0xFF,0xFF,0xF8,0x07,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x0F,0xFF,0xFE,
  151.       0xFF,0xFF,0xD0,0x07,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x03,0xFF,0xF8,
  152.       0xFF,0xFC,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xC0,
  153.       0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0xFF,0xF8,
  154.       0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x1F,0xFE,
  155.       0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x78,0x02,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,
  156.       0xFF,0x00,0x00,0x00,0x00,0x00,0x03,0xF0,0x78,0x00,0x00,0x00,0x00,0x00,0x02,0xFF,
  157.       0xFE,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,
  158.       0xF0,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,
  159.       0xE0,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,
  160.       0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x27,
  161.       0xC0,0x00,0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
  162.       0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,
  163.       0x80,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01
  164. };

  165. void set12864();
  166. void setxy(uchar x,uchar y);
  167. void write_command(uchar command);
  168. void write_16byte(uint data_add);
  169. void delays(uchar count);

  170. void main()
  171. {
  172.     uchar x,y,i;
  173.     while(1)
  174.     {
  175.         y="0x80";                     //设置液晶上半部分坐标
  176.         x="0x80";
  177.         delays(2);                  //延时2s
  178.         set12864();                 //初始化12864
  179.         delays(2);
  180.         for(i=0;i<32;i++)           //写入液晶上半图象部分
  181.         {                           //写入坐标
  182.             setxy(x,y);
  183.             write_16byte(i*16);     //连续写入16字节数据
  184.             y++;                    //y轴地址加1
  185.         }                           
  186.         y="0x80";                     //设置液晶下半部分坐标
  187.         x="0x88";
  188.         for(i=0;i<32;i++)           //写入液晶下半图象部分
  189.         {
  190.             setxy(x,y);             //写入坐标
  191.             write_16byte((32+i)*16);//连续写入16字节数据
  192.             y++;                    //y轴地址加1
  193.         }
  194.         write_command(0x34);        //写入扩充指令命令
  195.         write_command(0x36);        //显示图象
  196.     }
  197. }

  198. //初始化12864子程序
  199. void set12864()
  200. {
  201.     write_command(0x30);        //功能设定控制字
  202.     write_command(0x0c);        //显示开关控制字
  203.     write_command(0x01);        //清除屏幕控制字
  204.     write_command(0x06);        //进入设定点控制字
  205. }

  206. //设置绘图坐标
  207. void setxy(uchar x,uchar y)
  208. {                              
  209.     write_command(0x34);        //写入扩充指令命令
  210.     write_command(y);           //写入y轴坐标
  211.     write_command(x);           //写入x轴坐标
  212.     write_command(0x30);        //写入基本指令命令
  213. }

  214. //写控制命令子程序
  215. void write_command(uchar command)
  216. {
  217.     bit flag="1";                 //12864空闲标志位
  218.     while(flag)                 //检查12864是否空闲
  219.         flag="XBYTE"[comre]&0x80;
  220.     XBYTE[comwr]=command;       //空闲传送控制字
  221. }

  222. void write_16byte(uint data_add)
  223. {
  224.     bit flag="1";                 //12864空闲标志位
  225.     uchar num="16";               //16个循环,连续写入16个字节
  226.     for(;num>0;num--)
  227.     {
  228.         while(flag)             //检查12864是否空闲
  229.             flag="XBYTE"[comre]&0x80;
  230.         XBYTE[datawr]=disp_data[data_add++]; //空闲传送数据
  231.     }
  232. }

  233. //延时count秒子程序
  234. void delays(uchar count)
  235. {
  236.     unsigned char h,i,j,k;
  237.     do
  238.     {
  239.     for(h=5;h>0;h--)
  240.     for(i=4;i>0;i--)
  241.     for(j=116;j>0;j--)
  242.     for(k=214;k>0;k--);
  243.     }while(--count);
  244. }

复制代码
此帖出自单片机论坛

最新回复

果断复制粘贴!  详情 回复 发表于 2013-1-14 16:01
点赞 关注
个人签名http://www.mcuchina.cn 中国单片机培训网 51系列、PIC系列、AVR系列初级培训,长期招生。
 

回复
举报

74

帖子

0

TA的资源

一粒金砂(初级)

沙发
 

回复:12864液晶资料与原理图程序

谢谢哈,不过我已经有了,楼主也是从别的地方下的哟?
此帖出自单片机论坛
 
 

回复

242

帖子

0

TA的资源

纯净的硅(高级)

板凳
 

回复:12864液晶资料与原理图程序

虽然偶早就有了,不过还是帮楼主顶一下.
此帖出自单片机论坛
 
 
 

回复

12

帖子

0

TA的资源

一粒金砂(初级)

4
 

回复:12864液晶资料与原理图程序

谢谢共享啊!
此帖出自单片机论坛
 
 
 

回复

6

帖子

0

TA的资源

一粒金砂(中级)

5
 

回复:12864液晶资料与原理图程序

看看了
此帖出自单片机论坛
 
 
 

回复

46

帖子

0

TA的资源

纯净的硅(中级)

6
 

Re: 12864液晶资料与原理图程序

怎么不能下了...???????????:(
此帖出自单片机论坛
 
 
 

回复

2

帖子

0

TA的资源

一粒金砂(初级)

7
 

Re: 12864液晶资料与原理图程序

楼主辛苦了!!!
此帖出自单片机论坛
 
 
 

回复

2

帖子

0

TA的资源

一粒金砂(初级)

8
 
怎么下载不了啊!!!高人指点!!!
此帖出自单片机论坛

赞赏

1

查看全部赞赏

 
 
 

回复

19

帖子

0

TA的资源

一粒金砂(初级)

9
 
???
此帖出自单片机论坛
 
 
 

回复

19

帖子

0

TA的资源

一粒金砂(初级)

10
 
没有了
此帖出自单片机论坛
 
 
 

回复

157

帖子

0

TA的资源

纯净的硅(高级)

11
 
下不了。
此帖出自单片机论坛
 
 
 

回复

4

帖子

0

TA的资源

一粒金砂(初级)

12
 
是什么控制芯片
此帖出自单片机论坛
 
 
 

回复

100

帖子

0

TA的资源

一粒金砂(中级)

13
 
链接不在了》》??
此帖出自单片机论坛
 
 
 

回复

113

帖子

0

TA的资源

一粒金砂(中级)

14
 
果断复制粘贴!
此帖出自单片机论坛
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/7 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表