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

用C语言和51单片机来编三个简单的汉字在LCD12864不带字库的驱动是KS0108... 用C语言和51单片机来编三个简单的汉字在LCD12864不带字库的驱动是KS0108 展开
 我来答
百度网友b616da6
2009-10-16 · TA获得超过782个赞
知道小有建树答主
回答量:221
采纳率:0%
帮助的人:134万
展开全部
#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>0;num--)
{
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>0;num--)
{
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=5;h>0;h--)
for(i=4;i>0;i--)
for(j=116;j>0;j--)
for(k=214;k>0;k--);
}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,0x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,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=0;i<32;i++) //写入液晶上半图象部分
{ //写入坐标
setxy(x,y);
write_16byte(i*16); //连续写入16字节数据
y++; //y轴地址加1
}
y="0x80"; //设置液晶下半部分坐标
x="0x88";
for(i=0;i<32;i++) //写入液晶下半图象部分
{
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>0;num--)
{
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=5;h>0;h--)
for(i=4;i>0;i--)
for(j=116;j>0;j--)
for(k=214;k>0;k--);
}while(--count);
}
二花吼0G
2009-10-26 · TA获得超过210个赞
知道答主
回答量:43
采纳率:0%
帮助的人:0
展开全部
以下是源代码
/*******************************main.h******************************/
#ifndef _MAIN_H
#define _MAIN_H
#include <reg52.h>
#define LcdDataPort P2 //数据端口
#ifndef UCHAR_DEF
#define UCHAR_DEF
typedef unsigned char uchar;
#endif
sbit Reset = P3^0; //复位
sbit RS = P3^1; //指令数据选择
sbit E = P3^2; //指令数据控制
sbit CS1 = P3^4; //左屏幕选择,低电平有效
sbit CS2 = P3^5; //右屏幕选择
sbit RW = P3^3; //读写控制
sbit busy = P2^7; //忙标志
void SetOnOff(uchar onoff); //开关显示
void SelectScreen(uchar screen);//选择屏幕
void ClearScreen(uchar screen); //清屏
void Show1616(uchar lin,uchar colum,uchar *address);//显示一个汉字
void CheckState(); //判断状态
void LcdDelay(unsigned int time); //延时
void WriteData(uchar dat); //写数据
void SendCommand(uchar command); //写指令
void SetLine(uchar line); //置行地址
void SetColum(uchar colum);//置列地址
void SetStartLine(uchar startline);//置显示起始行
void InitLcd(); //初始化
void ResetLcd(); //复位
#endif
/*********************************************************************/
/***********************************lcd.c****************************************/
#include "main.h"
void CheckState()
{
E = 1;
RS = 0;
RW = 1;
LcdDataPort = 0xff;
while(!busy);
}
void LcdDelay(unsigned int time)
{
while(time --);
}
void WriteData(uchar dat)
{
CheckState();
E = 1;
RS = 1;
RW = 0;
LcdDataPort = dat;
E = 0;
}
void SendCommand(uchar command)
{
CheckState();
E = 1;
RW = 0;
RS = 0;
LcdDataPort = command;
E = 0;
}
void SelectScreen(uchar screen) //0-全屏,1—左屏,2-右屏
{
switch(screen)
{
case 0 :
CS1 = 0;
LcdDelay(2);
CS2 = 1;
LcdDelay(2);
break;
case 1 :
CS1 = 1;
LcdDelay(2);
CS2 = 0;
LcdDelay(2);
break;
case 2 :
CS1 = 0;
LcdDelay(2);
CS2 = 0;
LcdDelay(2);
break;
}
}
void ClearScreen(uchar screen) // screen 0-全屏,1—左屏,2-右屏
{
uchar i,j;
SelectScreen(screen);
for(i = 0;i < 8;i ++)
{
SetLine(i);
SetColum(0);
for(j = 0;j < 64; j ++)
WriteData(0);
}
}
void SetLine(uchar line) //line -> 0 : 7
{
line = line & 0x07;
line = line | 0xb8; //1011 1xxx
SendCommand(line);
}
void SetColum(uchar colum) //colum -> 0 :63
{
colum = colum & 0x3f;
colum = colum | 0x40; //01xx xxxx
SendCommand(colum);
}
void SetStartLine(uchar startline) //startline -> 0 : 63
{
startline = startline & 0x3f;
startline = startline | 0xc0; //11xxxxxx
SendCommand(startline);
}
void SetOnOff(uchar onoff) //1-开显示 0-关
{
if(onoff == 1)
SendCommand(0x3f); //0011 111x
else
SendCommand(0x3e);
}
void ResetLcd()
{
Reset = 0;
LcdDelay(2);
Reset = 1;
LcdDelay(2);
RS0 = 0;
LcdDelay(2);
RS1 = 0;
LcdDelay(2);
SetOnOff(1);
}
void InitLcd()
{
ResetLcd();
SetOnOff(0);
ClearScreen(2);
SetLine(0);
SetColum(0);
SetStartLine(0);
SetOnOff(1);
}
void Show1616(uchar lin,uchar colum,uchar *address)
{
uchar i;
SetLine(lin);
SetColum(colum);
for(i = 0;i < 16;i ++)
WriteData(*(address ++));
SetLine(lin + 1);
SetColum(colum);
for(i = 0;i < 16;i ++)
WriteData(*(address ++));
}
/*******************************************************************************/
/********************************main.c***********************************************/
#include <reg52.h>
#include "main.h"
const uchar code HZ_tab[] = {
0x10,0x21,0x62,0x06,0x82,0xE2,0x22,0x22,
0x22,0xF2,0x22,0x02,0xFE,0x03,0x02,0x00, //河
0x04,0x04,0xFE,0x01,0x00,0x0F,0x04,0x04,
0x04,0x0F,0x40,0x80,0x7F,0x00,0x00,0x00,
0x04,0xE4,0x24,0x24,0x64,0xA4,0x24,0x3F,
0x24,0xA4,0x64,0x24,0x24,0xF6,0x24,0x00, //南
0x00,0xFF,0x00,0x09,0x09,0x09,0x09,0x7F,
0x09,0x09,0x09,0x49,0x80,0x7F,0x00,0x00,
0x24,0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,
0x24,0x48,0x00,0xFF,0x00,0x80,0x00,0x00, //科
0x10,0x08,0x06,0x01,0xFF,0x00,0x01,0x02,
0x02,0x02,0x02,0xFF,0x01,0x01,0x01,0x00,
0x10,0x10,0x10,0xFF,0x10,0x10,0x88,0x88,
0x88,0xFF,0x88,0x88,0x8C,0x08,0x00,0x00, //技
0x04,0x44,0x82,0x7F,0x01,0x80,0x81,0x46,
0x28,0x10,0x28,0x26,0x41,0xC0,0x40,0x00,
0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,
0xA0,0x20,0x20,0x20,0x20,0x30,0x20,0x00, //大
0x00,0x40,0x40,0x20,0x10,0x0C,0x03,0x00,
0x01,0x06,0x08,0x10,0x20,0x60,0x20,0x00,
0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,
0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00, //学
0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,
0x06,0x05,0x04,0x04,0x04,0x06,0x04,0x00,
0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,
0x48,0x48,0x48,0xFC,0x08,0x00,0x00,0x00, //电
0x00,0x07,0x02,0x02,0x02,0x02,0x3F,0x42,
0x42,0x42,0x42,0x47,0x40,0x70,0x00,0x00,
0x80,0x80,0x82,0x82,0x82,0x82,0x82,0xE2,
0xA2,0x92,0x8A,0x86,0x80,0xC0,0x80,0x00, //子
0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x40,0x20,0xF8,0x07,0x24,0x24,0x24,
0x25,0x26,0x24,0x24,0xB4,0x26,0x04,0x00, //信
0x00,0x00,0x00,0xFF,0x00,0x01,0xFD,0x45,
0x45,0x45,0x45,0x45,0xFD,0x01,0x00,0x00,
0x00,0x00,0x00,0xFC,0xA4,0xA6,0xA5,0xA4,
0xA4,0xA4,0xA4,0xFE,0x04,0x00,0x00,0x00, //息
0x40,0x30,0x00,0x77,0x84,0x84,0x8C,0x94,
0xB4,0x84,0x84,0xE7,0x00,0x10,0x60,0x00,
0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,
0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00, //工
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,
0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x00,
0x24,0x24,0xA4,0xFE,0xA3,0x22,0x20,0x7E,
0x42,0x42,0x42,0x42,0x42,0x7F,0x02,0x00, //程
0x08,0x06,0x01,0xFF,0x00,0x43,0x41,0x49,
0x49,0x49,0x7F,0x49,0x4D,0x69,0x41,0x00,
0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,
0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00, //学
0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,
0x06,0x05,0x04,0x04,0x04,0x06,0x04,0x00,
0x00,0xFE,0x22,0x5A,0x96,0x0C,0x24,0x24,
0x25,0x26,0x24,0x34,0xA4,0x14,0x0C,0x00, // 院
0x00,0xFF,0x04,0x08,0x87,0x81,0x41,0x31,
0x0F,0x01,0x3F,0x41,0x41,0x41,0x70,0x00
};

void main()
{
uchar i,line,colum ;
uchar *address ;
InitLcd();
while(1)
{
colum = 16;
line = 1;
address = HZ_tab;
SetOnOff(0); //关显示
for(i = 1;i < 7;i ++)
{
if(i < 4)
SelectScreen(0);
else
SelectScreen(1);
Show1616(line,colum ,address);
colum += 16;
if(colum >63)
colum = 0;
address += 32; //向DDRAM中写入数据
}
line = 5;
colum = 0;
for(i = 0;i <8; i ++)
{
if(i < 4)
SelectScreen(0);
else
SelectScreen(1);
Show1616(line,colum ,address);
colum += 16;
if(colum >63)
colum = 0;
address += 32;
}
SelectScreen(2);
SetOnOff(1); // 开显示
for(i = 0;i < 50;i ++) //延时
LcdDelay(30000);
}
}
/********************************************************************************/
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
ypfengye
推荐于2016-08-17 · 超过16用户采纳过TA的回答
知道答主
回答量:79
采纳率:0%
帮助的人:33.4万
展开全部
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit LCD_RS=P3^5;
sbit LCD_RW=P3^6;
sbit LCD_E=P3^4;
sbit LCD_PSB=P3^7; //液晶有关控制位
uchar code dis1[]={"一片枫叶"};

/*=====================延时===========================*/
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}

//写指令
void write_com(uchar com)
{
LCD_RS=0;
LCD_RW=0;
LCD_E=0;
P0=com;
delay(5);
LCD_E=1;
delay(5);
LCD_E=0;
}
//写数据{
void write_date(uchar date)
{
LCD_RS=1;
LCD_RW=0;
LCD_E=0;
P0=date;
delay(5);
LCD_E=1;
delay(5);
LCD_E=0;
}
//初始化液晶
void chushi()
{
P0=0x7f;
LCD_PSB=1;
write_com(0x30);
delay(5);
write_com(0x0c);
delay(5);
write_com(0x01);
delay(5);
for(num=0;num<5;num++)
{
write_date(dis1[num]);
delay(20);
}
}

}
/*=======================主函数=========================*/
void main()
{

chushi();

}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式