12864液晶不带字库的用C语言和51单片机编程

12864液晶不带字库的用C语言和51单片机编程,第1张

#include<reg51.h>

#include<absacc.h>

#define uchar unsigned char

#define datawr 0x1200 //写数据通道

#define comwr 0x1000//写控制命令通道

#define datare 0x1300 //读数据通道

#define comre 0x1100//读忙通道

uchar code disp_data[]={"浙江大学" //第一行,第一页

"04级通信工程一班" //第三行

" 宁波理工学院 " //第二行

"竞赛小组" //第四行

"128X64液晶显示器" //第一行,第二页

"测试程序" //第三行

" 07年07月25日 " //第二行

"Tornado "} //第四行

void set12864()

void write_command(uchar command)

void write_page(uchar data_add)

void read_page(uchar data_add)

void delays(uchar cont)

void main()

{

while(1)

{

set12864()//初始化12864

write_page(0) //写入一页数据

read_page(0x30) //读出一页数据到内部RAM

delays(2) //延时2s

write_page(64)//写入下一页数据

delays(2) //延时2s

}

}

//初始化12864子程序

void set12864()

{

write_command(0x30) //功能设定控制字

write_command(0x0c) //显示开关控制字

write_command(0x01) //清除屏幕控制字

write_command(0x06) //进入设定点控制字

}

//写控制命令子程序

void write_command(uchar command)

{

bit flag="1"//12864空闲标志位

while(flag) //检查12864是否空闲

flag="XBYTE"[comre]&0x80

XBYTE[comwr]=command //空闲传送控制字

}

//写一页子程序

void write_page(uchar data_add)

{

bit flag="1"//12864空闲标志位

uchar num="64" //64个循环,连续写入32个汉字或是64个西文字符

write_command(0x80)

for(num>0num--)

{

while(flag) //检查12864是否空闲

flag="XBYTE"[comre]&0x80

XBYTE[datawr]=disp_data[data_add++]//空闲传送数据

}

}

//读一页子程序

void read_page(uchar data_add)

{

bit flag="1"//12864空闲标志位

uchar num="64" //64个循环,连续写入32个汉字或是64个西文字符

write_command(0x80)

for(num>0num--)

{

while(flag) //检查12864是否空闲

flag="XBYTE"[comre]&0x80

DBYTE[data_add++]=XBYTE[datare]//空闲传送数据

}

}

//延时cont秒子程序

void delays(uchar count)

{

unsigned char h,i,j,k

do

{

for(h=5h>0h--)

for(i=4i>0i--)

for(j=116j>0j--)

for(k=214k>0k--)

}while(--count)

}

这是图象显示程序:

#include<reg51.h>

#include<absacc.h>

#define uchar unsigned char

#define uint unsigned int

#define datawr 0x1200 //写数据通道

#define comwr 0x1000//写控制命令通道

#define datare 0x1300 //读数据通道

#define comre 0x1100//读忙通道

uchar code disp_data[] =// 数据表

{

0x00,0x01,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,

0x00,0x01,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,

0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,

0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,

0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,

0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,

0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,

0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x80,0x00,0x00,0x00,

0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0xFF,0xFF,0xFF,

0x00,0xFF,0xFF,0xFF,0xFF,0xFF,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xFF,0xFF,

0x85,0x2A,0xC0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,

0xBF,0xF3,0xC0,0x00,0x00,0x00,0x00,0x00,0xFF,0xF7,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,

0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,

0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0xFF,0xC0,0xFF,0xFF,0xFF,0xFF,0xC0,0x1F,

0xFF,0xFF,0x80,0x00,0x40,0x00,0x00,0x00,0xFF,0x80,0xFF,0xFF,0xFF,0x80,0x07,0xFF,

0xFF,0xFF,0xC0,0x00,0xC0,0x00,0x00,0x01,0xFF,0x01,0xFF,0xFF,0xF8,0x00,0xFF,0xFF,

0xFF,0xFF,0xE0,0x63,0x80,0x00,0x00,0x01,0xFE,0x01,0xFF,0x18,0x00,0x3F,0xFF,0xFF,

0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x01,0xCC,0x01,0xFE,0x00,0x07,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x07,0xA0,0x03,0xFC,0x00,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x05,0xC0,0x03,0xC8,0x00,0x7F,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x88,0x0C,0x07,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFC,0x00,0x0C,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0xC0,0x7F,0xFF,0xFF,

0xFF,0xFF,0xF8,0x07,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x0F,0xFF,0xFE,

0xFF,0xFF,0xD0,0x07,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x03,0xFF,0xF8,

0xFF,0xFC,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xC0,

0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0xFF,0xF8,

0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x1F,0xFE,

0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x78,0x02,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,

0xFF,0x00,0x00,0x00,0x00,0x00,0x03,0xF0,0x78,0x00,0x00,0x00,0x00,0x00,0x02,0xFF,

0xFE,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,

0xF0,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,

0xE0,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,

0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x27,

0xC0,0x00,0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,

0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,

0x80,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01

}

void set12864()

void setxy(uchar x,uchar y)

void write_command(uchar command)

void write_16byte(uint data_add)

void delays(uchar count)

void main()

{

uchar x,y,i

while(1)

{

y="0x80"//设置液晶上半部分坐标

x="0x80"

delays(2) //延时2s

set12864()//初始化12864

delays(2)

for(i=0i<32i++) //写入液晶上半图象部分

{ //写入坐标

setxy(x,y)

write_16byte(i*16)//连续写入16字节数据

y++ //y轴地址加1

}

y="0x80"//设置液晶下半部分坐标

x="0x88"

for(i=0i<32i++) //写入液晶下半图象部分

{

setxy(x,y)//写入坐标

write_16byte((32+i)*16)//连续写入16字节数据

y++ //y轴地址加1

}

write_command(0x34) //写入扩充指令命令

write_command(0x36) //显示图象

}

}

//初始化12864子程序

void set12864()

{

write_command(0x30) //功能设定控制字

write_command(0x0c) //显示开关控制字

write_command(0x01) //清除屏幕控制字

write_command(0x06) //进入设定点控制字

}

//设置绘图坐标

void setxy(uchar x,uchar y)

{

write_command(0x34) //写入扩充指令命令

write_command(y) //写入y轴坐标

write_command(x) //写入x轴坐标

write_command(0x30) //写入基本指令命令

}

//写控制命令子程序

void write_command(uchar command)

{

bit flag="1"//12864空闲标志位

while(flag) //检查12864是否空闲

flag="XBYTE"[comre]&0x80

XBYTE[comwr]=command //空闲传送控制字

}

void write_16byte(uint data_add)

{

bit flag="1"//12864空闲标志位

uchar num="16" //16个循环,连续写入16个字节

for(num>0num--)

{

while(flag) //检查12864是否空闲

flag="XBYTE"[comre]&0x80

XBYTE[datawr]=disp_data[data_add++]//空闲传送数据

}

}

//延时count秒子程序

void delays(uchar count)

{

unsigned char h,i,j,k

do

{

for(h=5h>0h--)

for(i=4i>0i--)

for(j=116j>0j--)

for(k=214k>0k--)

}while(--count)

}

12864带字库的就是可以直接输入汉字而不需要用点阵生成器把汉字变成点阵后再输入,因为带字库的12864里面已经有汉字的点阵了。

至于取模软件根据功能自作者的不同,用法也不同,需要的话我可以把我的给你,功能还是很强的

首先,一个开发环境能否仿真一种器件,取决于驱动程序,没有相关仿真驱动程序是没办法仿真器件的。由于液晶屏控制芯片种类繁多,标准不一,很难仿真。

如果你的开发环境支持液晶屏仿真,你的想法是可以的,但是你的程序和接线方法都改了,这仿真还有什么意义?


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11110181.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-13
下一篇 2023-05-13

发表评论

登录后才能评论

评论列表(0条)

保存