发表于:2010/6/29 22:00:18
#0楼
//--------------------------------------------------
//主程序
//--------------------------------------------------
void main(void)
{
//单片机初始化
init_st7920();
delayms(20);
dishz(1,3,第一行空二格);
dishz(2,5,第二行);
dishz(3,7,第三行);
dishz(4,9,第四行);
while(1);
}
//*******************************************************************
//-------------------------------------------------------------------
//lg256641测试程序:st7920p.c
//驱动芯片st7920,使用并行通信格式
//-------------------------------------------------------------------
//*******************************************************************
#include
sbit e1=p2^2; //13
sbit e2=p2^3; //14
sbit rs=p2^4; //15
sbit rw=p2^5; //16
//-------------------------------------------------------------------
//延时子程序
//-------------------------------------------------------------------
void delayus(int us)
{
unsigned int i;
for(i=0;i
void delayms(int ms)
{
unsigned int i;
for(i=0;i
//-------------------------------------------------------------------
//读指令
//-------------------------------------------------------------------
unsigned char readcmd(unsigned char band)
{
unsigned char tmp;
rs = 0;
rw = 1;
p0=0xff;
if(band==1)e1= 1;
if(band==2)e2= 1;
delayus(1); //延时根据时序图的要求及所采用的晶振来确定
tmp=p0;
e1 = 0;
e2 = 0;
return tmp;
}
//-------------------------------------------------------------------
//忙检测
//-------------------------------------------------------------------
void busy(unsigned char band)
{
while(readcmd(band)&0x80);
}
//-------------------------------------------------------------------
//写指令
//-------------------------------------------------------------------
void writecmd(unsigned char band,unsigned char cmd)
{
busy(band);
rs = 0;
rw = 0;
if(band==1)e1= 1;
if(band==2)e2= 1;
p0 = cmd;
delayus(1); //延时根据时序图的要求及所采用的晶振来确定
e1 = 0;
e2 = 0;
}
//-------------------------------------------------------------------
//写数据
//-------------------------------------------------------------------
void writedat(unsigned char band,unsigned char dat)
{
busy(band);
rs = 1;
rw = 0;
if(band==1)e1= 1;
if(band==2)e2= 1;
p0 = dat;
delayus(1); //延时根据时序图的要求及所采用的晶振来确定
e1 = 0;
e2 = 0;
}
//-------------------------------------------------------------------
//显示汉字
//x表示行号,y表示列号,*s表示字符串。
//注意字符串中相邻的字母或数字出现奇数时,以空格补齐偶数
//-------------------------------------------------------------------
void dishz(unsigned char x,unsigned char y,unsigned char *s)
{
unsigned char ch;
if(y>0)y--;
if(x
//-------------------------------------------------------------------
//st7920初始化
//-------------------------------------------------------------------
void init_st7920(void)
{
e1=0;
e2=0;
writecmd(1,0x30);
writecmd(2,0x30);
writecmd(1,0x0c);
writecmd(2,0x0c);
writecmd(1,0x01);
writecmd(2,0x01);
busy(1);
busy(2);
}
----------------------------------------------
此篇文章从博客转发
原文地址: Http://blog.gkong.com/more.asp?id=118422&Name=zhouchs
//主程序
//--------------------------------------------------
void main(void)
{
//单片机初始化
init_st7920();
delayms(20);
dishz(1,3,第一行空二格);
dishz(2,5,第二行);
dishz(3,7,第三行);
dishz(4,9,第四行);
while(1);
}
//*******************************************************************
//-------------------------------------------------------------------
//lg256641测试程序:st7920p.c
//驱动芯片st7920,使用并行通信格式
//-------------------------------------------------------------------
//*******************************************************************
#include
sbit e1=p2^2; //13
sbit e2=p2^3; //14
sbit rs=p2^4; //15
sbit rw=p2^5; //16
//-------------------------------------------------------------------
//延时子程序
//-------------------------------------------------------------------
void delayus(int us)
{
unsigned int i;
for(i=0;i
void delayms(int ms)
{
unsigned int i;
for(i=0;i
//-------------------------------------------------------------------
//读指令
//-------------------------------------------------------------------
unsigned char readcmd(unsigned char band)
{
unsigned char tmp;
rs = 0;
rw = 1;
p0=0xff;
if(band==1)e1= 1;
if(band==2)e2= 1;
delayus(1); //延时根据时序图的要求及所采用的晶振来确定
tmp=p0;
e1 = 0;
e2 = 0;
return tmp;
}
//-------------------------------------------------------------------
//忙检测
//-------------------------------------------------------------------
void busy(unsigned char band)
{
while(readcmd(band)&0x80);
}
//-------------------------------------------------------------------
//写指令
//-------------------------------------------------------------------
void writecmd(unsigned char band,unsigned char cmd)
{
busy(band);
rs = 0;
rw = 0;
if(band==1)e1= 1;
if(band==2)e2= 1;
p0 = cmd;
delayus(1); //延时根据时序图的要求及所采用的晶振来确定
e1 = 0;
e2 = 0;
}
//-------------------------------------------------------------------
//写数据
//-------------------------------------------------------------------
void writedat(unsigned char band,unsigned char dat)
{
busy(band);
rs = 1;
rw = 0;
if(band==1)e1= 1;
if(band==2)e2= 1;
p0 = dat;
delayus(1); //延时根据时序图的要求及所采用的晶振来确定
e1 = 0;
e2 = 0;
}
//-------------------------------------------------------------------
//显示汉字
//x表示行号,y表示列号,*s表示字符串。
//注意字符串中相邻的字母或数字出现奇数时,以空格补齐偶数
//-------------------------------------------------------------------
void dishz(unsigned char x,unsigned char y,unsigned char *s)
{
unsigned char ch;
if(y>0)y--;
if(x
//-------------------------------------------------------------------
//st7920初始化
//-------------------------------------------------------------------
void init_st7920(void)
{
e1=0;
e2=0;
writecmd(1,0x30);
writecmd(2,0x30);
writecmd(1,0x0c);
writecmd(2,0x0c);
writecmd(1,0x01);
writecmd(2,0x01);
busy(1);
busy(2);
}
----------------------------------------------
此篇文章从博客转发
原文地址: Http://blog.gkong.com/more.asp?id=118422&Name=zhouchs
欢迎光临我的BLOG