还没有显示,我的电路是一个AT89C51连接了一个液晶,别的什么也没连,用的液晶是汉升19264-6的液晶,哪位用过的帮忙给看看,谢谢
//***************************************************************************
//连线表: CPU=89C52 *
//RS=P3.0 RW=P3.1 E=P3.2 CS1=3.3 CS2=3.4 *
//FOSC=12MHz D0-D7=P1.0-P1.7 *
//***************************************************************************
#include
sbit RS=P3^2;
sbit RW=P3^1;
sbit E=P3^0;
sbit CS1=P3^3;
sbit CS2=P3^4;
#define DATA_BUS P1
void wr_lcd_1(unsigned char dat_com,unsigned char content);
void wr_lcd_2(unsigned char dat_com,unsigned char content);
void wr_lcd_3(unsigned char dat_com,unsigned char content);
void delay_us(unsigned int us_value);
void delay_ms(unsigned int ms_value);
void init_lcd (void);
void disp_dots(unsigned char data1,unsigned char data2);
void disp_img(unsigned char code *img);
void clr_ram(void);
void main(void);
unsigned char code img1[];
char code han[]={
/*-- 文字: 汉 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x60,0x01,0x86,0x60,0x04,0x1C,0xE4,0x04,0x04,0x04,0xE4,0x1C,0x04,0x00,0x00,
0x04,0x04,0x7E,0x01,0x40,0x20,0x20,0x10,0x0B,0x04,0x0B,0x10,0x30,0x60,0x20,0x00,
};
/******************************************************************************************
*函数名称: init_lcd
*功能描述: 初始化
******************************************************************************************/
void init_lcd (void)
{
wr_lcd_1(0,0xc0);
wr_lcd_1(0,0x3f);
wr_lcd_2(0,0xc0);
wr_lcd_2(0,0x3f);
wr_lcd_3(0,0xc0);
wr_lcd_3(0,0x3f);
}
/******************************************************************************************
*函数名称:wr_lcd_1
*功能描述:左屏写入指令/数据子程序
******************************************************************************************/
void wr_lcd_1(unsigned char dat_com,unsigned char content)
{
CS1=0;
CS2=0;
// ck_busy();
if(dat_com)
{
RS = 1; //data
RW = 0; //write
}
else
{
RS = 0; //com
RW = 0; //write
}
P1=content; //iutput data or com
E = 1;
E = 0;
}
/******************************************************************************************
*函数名称:wr_lcd_2
*功能描述:中屏写入指令/数据子程序
******************************************************************************************/
void wr_lcd_2(unsigned char dat_com,unsigned char content)
{
CS1=0;
CS2=1;
//ck_busy();
if(dat_com)
{
RS = 1; //data
RW = 0; //write
}
else
{
RS = 0; //com
RW = 0; //write
}
P1=content; //iutput data or com
E = 1;
E = 0;
}
/******************************************************************************************
*函数名称:wr_lcd_3
*功能描述:右屏写入指令/数据子程序
******************************************************************************************/
void wr_lcd_3(unsigned char dat_com,unsigned char content)
{
CS1=1;
CS2=0;
//ck_busy();
if(dat_com)
{
RS = 1; //data
RW = 0; //write
}
else
{
RS = 0; //com
RW = 0; //write
}
P1=content; //iutput data or com
E = 1;
E = 0;
}
/******************************************************************************************
****************************************************************************************
*函数名称:delay_us
*功能描述:延时us
******************************************************************************************/
void delay_us(unsigned int us_value) //delay time
{
while(us_value--);
}
/******************************************************************************************
*函数名称:delay_ms
*功能描述:延时ms
******************************************************************************************/
void delay_ms(unsigned int ms_value)
{
unsigned int i,j;
for(i=0;i
for(j=0;j<15;j++)
delay_us(1);
}
/******************************************************************************************
*函数名称:Disp_dots
*功能描述:显示点、横、竖
******************************************************************************************/
void disp_dots(unsigned char data1,unsigned char data2)
{
unsigned char i,j;
for(j=0;j<8;j++)
{
for(i=0;i<32;i++)
{
wr_lcd_1(0,0xb8+j);
wr_lcd_1(0,0x40+i*2);
wr_lcd_1(1,data1);
wr_lcd_1(0,0x40+i*2+1);
wr_lcd_1(1,data2);
wr_lcd_2(0,0xb8+j);
wr_lcd_2(0,0x40+i*2);
wr_lcd_2(1,data1);
wr_lcd_2(0,0x40+i*2+1);
wr_lcd_2(1,data2);
wr_lcd_3(0,0xb8+j);
wr_lcd_3(0,0x40+i*2);
wr_lcd_3(1,data1);
wr_lcd_3(0,0x40+i*2+1);
wr_lcd_3(1,data2);
}
}
}
/******************************************************************************************
*函数名称:disp_img
*功能描述:显示图片
******************************************************************************************/
void disp_img(unsigned char code *img)
{
unsigned char j,k;
for(k=0;k<8;k++)
{
for(j=0;j<64;j++)
{
wr_lcd_1(0,0xb8+k);
wr_lcd_1(0,0x40+j);
wr_lcd_1(1,img[k*192+j]);
}
for(j=64;j<128;j++)
{
wr_lcd_2(0,0xb8+k);
wr_lcd_2(0,0x40+j-64);
wr_lcd_2(1,img[k*192+j]);
}
for(j=128;j<192;j++)
{
wr_lcd_3(0,0xb8+k);
wr_lcd_3(0,0x40+j-128);
wr_lcd_3(1,img[k*192+j]);
}
}
}
/******************************************************************************************
*函数名称:clr_ram
*功能描述:清除内存
******************************************************************************************/
void clr_ram()
{
unsigned char j,k;
for(k=0;k<8;k++)
{
for(j=0;j<64;j++)
{
wr_lcd_1(0,0xb8+k);
wr_lcd_1(0,0x40+j);
wr_lcd_1(1,0);
wr_lcd_2(0,0xb8+k);
wr_lcd_2(0,0x40+j);
wr_lcd_2(1,0);
wr_lcd_3(0,0xb8+k);
wr_lcd_3(0,0x40+j);
wr_lcd_3(1,0);
}
}
}
/******************************************************************************************
*函数名称: disp_cn_1
*功能描述: 左屏显示单个汉字
******************************************************************************************/
void disp_cn_1(unsigned char code *cn,unsigned char page,unsigned char col)
{
unsigned char i,j;
for(j=0;j<2;j++)
{
for(i=0;i<16;i++)
{
wr_lcd_1(0,0xb8+page+j);
wr_lcd_1(0,0x40+col+i);
wr_lcd_1(1,cn[j*16+i]);
}
}
}
/******************************************************************************************
*函数名称: disp_cn_2
*功能描述: 中屏显示单个汉字
******************************************************************************************/
void disp_cn_2(unsigned char code *cn,unsigned char page,unsigned char col)
{
unsigned char i,j;
for(j=0;j<2;j++)
{
for(i=0;i<16;i++)
{
wr_lcd_2(0,0xb8+page+j);
wr_lcd_2(0,0x40+col+i);
wr_lcd_2(1,cn[j*16+i]);
}
}
}
/******************************************************************************************
*函数名称: disp_cn_3
*功能描述: 右屏显示单个汉字
******************************************************************************************/
void disp_cn_3(unsigned char code *cn,unsigned char page,unsigned char col)
{
unsigned char i,j;
for(j=0;j<2;j++)
{
for(i=0;i<16;i++)
{
wr_lcd_3(0,0xb8+page+j);
wr_lcd_3(0,0x40+col+i);
wr_lcd_3(1,cn[j*16+i]);
}
}
}
/******************************************************************************************
*函数名称: main
*功能描述: 主程序
******************************************************************************************/
void main()
{
delay_ms(40);
init_lcd();
clr_ram();
while(1)
{
disp_dots(0xff,0xff);
delay_ms(800);
disp_dots(0x55,0xaa);
delay_ms(800);
disp_dots(0xaa,0xaa);
delay_ms(800);
disp_dots(0x55,0x55);
delay_ms(800);
disp_dots(0xaa,0xaa);
delay_ms(800);
disp_dots(0xff,0x00);
delay_ms(800);
disp_dots(0x00,0xff);
delay_ms(800);
clr_ram();
disp_cn_1(han,2,0);
delay_ms(800);
clr_ram();
}
}
|