T6963C控制器的液晶显示模块程序

2023-04-15 18:00   248   0  

/*


线路图


89C51 T6963C


--------


| 8


P1.0-1.7|=========== D0-7


|


P3.0|----------- /RD


P3.1|----------- /WR


P3.2|----------- C/D


| -- /CE


| |


| ---


P3.3|----------- /RESET


| VCC--- /HALT


--------


*/


#include

#include

#include


sbit cd=P3^2;

sbit wr=P3^1;

sbit rd=P3^0;

sbit reset=P3^3;

sbit vee=P3^7;


sbit scl=P3^2;

sbit sda=P3^3;


unsigned int time;

unsigned char x,y;


/* 忙标志 */

#pragma disable

unsigned char busy(void) {

unsigned char dat;

cd=1;rd=1;wr=1;

P0=0xff;

rd=0;

dat=P0;

rd=1;

return(dat);

}

/* 数据,指令读写判别 */

#pragma disable

void p1(void) {

while ((busy()&3)!=3) {}

}

/* 数据自动读判别 */

#pragma disable

void p2(void) {

while ((busy()&4)!=4) {}

}

/* 数据自动写判别 */

#pragma disable

void p3(void) {

while ((busy()&8)!=8) {}

}

/* 控制指令 */

#pragma disable

void ctrl(unsigned char dat) {

p1();

cd=1;

wr=0;

P0=dat;

wr=1;

}

/* 写数据 */

#pragma disable

void write(unsigned char dat) {

p1();

cd=0;

wr=0;

P0=dat;

wr=1;

cd=1;

}

/* 自动写 */

#pragma disable

void autowrite(unsigned char dat) {

p3();

cd=0;

wr=0;

P0=dat;

wr=1;

cd=1;

}

/* 读数据 */

#pragma disable

unsigned char read(void) {

unsigned char dat;

p1();

cd=0;

P0=0xff;

rd=0;

dat=P0;

rd=1;

cd=1;

return(dat);

}

/* 自动读数据 */

#pragma disable

unsigned char autoread(void) {

unsigned char dat;

p2();

cd=0;

P0=0xff;

rd=0;

dat=P0;

rd=1;

cd=1;

return(dat);

}

/* 显示图形和文本 */

#pragma disable

void disp(unsigned char d) { /*显示*/

write(d);ctrl(0xc0);

}

/* 设定图形x,y值*/

#pragma disable

void ag(unsigned char x,unsigned char y) { /*地址*/

unsigned int xy;

xy=y;

xy=xy*16+x+256;

write(xy&0xff);write(xy/256);ctrl(0x24);

}

/* 设定文本x,y值 */

#pragma disable

void at(unsigned char x,unsigned char y) { /*地址*/

write(y*16+x);write(0);ctrl(0x24);

}

/* 点亮一点 */

#pragma disable

void setb(unsigned char d) {

ctrl(0xf8|d);

}

/* 清除一点*/

#pragma disable

void clrb(unsigned char d) {

ctrl(0xf0|d);

}

/* x,y处显示光标 */

#pragma disable

void ab(unsigned char x,unsigned char y) { /*光标*/

ctrl(0x97); /*光标开*/

write(x);write(y);ctrl(0x21);

}

/* 取消光标 */

#pragma disable

void noab(void) {

ctrl(0x9c);

}


/* lcd初始化 */

void init(void) {

unsigned int i;

reset=0;

reset=1;

write(0x0);write(0);ctrl(0x40); /*文本首址*/

write(0x10);write(0x0);ctrl(0x41); /*文本区域*/

write(0x0);write(0x1);ctrl(0x42); /*图形首址*/

write(0x10);write(0x0);ctrl(0x43); /*图形区域*/

ctrl(0x81); /*显示方式*/

ctrl(0x90); /*显示开关*/

ctrl(0xa0); /*光标形状*/

at(0,0);

ctrl(0xb0); /*自动写方式*/

for (i=0;i<1280;i++) {

autowrite(0x0);

}

ctrl(0xb2);/*结束自动写方式 */

ctrl(0x9c);

}


void wait10(void) {

time=0;

while (time<10) {}

}


unsigned char temp;

unsigned char code asc16[]={

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

0,0,126,129,165,129,129,189,153,129,129,126,0,0,0,0,

0,0,126,255,219,255,255,195,231,255,255,126,0,0,0,0,

0,0,0,0,108,254,254,254,254,124,56,16,0,0,0,0,

0,0,0,0,16,56,124,254,124,56,16,0,0,0,0,0,

0,0,0,24,60,60,231,231,231,24,24,60,0,0,0,0,

0,0,0,24,60,126,255,255,126,24,24,60,0,0,0,0,

0,0,0,0,0,0,24,60,60,24,0,0,0,0,0,0,

255,255,255,255,255,255,231,195,195,231,255,255,255,255,255,255,

0,0,0,0,0,60,102,66,66,102,60,0,0,0,0,0,

255,255,255,255,255,195,153,189,189,153,195,255,255,255,255,255,

0,0,30,14,26,50,120,204,204,204,204,120,0,0,0,0,

0,0,60,102,102,102,102,60,24,126,24,24,0,0,0,0,

0,0,63,51,63,48,48,48,48,112,240,224,0,0,0,0,

0,0,127,99,127,99,99,99,99,103,231,230,192,0,0,0,

0,0,0,24,24,219,60,231,60,219,24,24,0,0,0,0,

0,128,192,224,240,248,254,248,240,224,192,128,0,0,0,0,

0,2,6,14,30,62,254,62,30,14,6,2,0,0,0,0,

0,0,24,60,126,24,24,24,126,60,24,0,0,0,0,0,

0,0,102,102,102,102,102,102,102,0,102,102,0,0,0,0,

0,0,127,219,219,219,123,27,27,27,27,27,0,0,0,0,

0,124,198,96,56,108,198,198,108,56,12,198,124,0,0,0,

0,0,0,0,0,0,0,0,254,254,254,254,0,0,0,0,

0,0,24,60,126,24,24,24,126,60,24,126,0,0,0,0,

0,0,24,60,126,24,24,24,24,24,24,24,0,0,0,0,

0,0,24,24,24,24,24,24,24,126,60,24,0,0,0,0,

0,0,0,0,0,24,12,254,12,24,0,0,0,0,0,0,

0,0,0,0,0,48,96,254,96,48,0,0,0,0,0,0,

0,0,0,0,0,0,192,192,192,254,0,0,0,0,0,0,

0,0,0,0,0,40,108,254,108,40,0,0,0,0,0,0,

0,0,0,0,16,56,56,124,124,254,254,0,0,0,0,0,

0,0,0,0,254,254,124,124,56,56,16,0,0,0,0,0,

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

0,0,24,60,60,60,24,24,24,0,24,24,0,0,0,0,

0,102,102,102,36,0,0,0,0,0,0,0,0,0,0,0,

0,0,0,108,108,254,108,108,108,254,108,108,0,0,0,0,

24,24,124,198,194,192,124,6,6,134,198,124,24,24,0,0,

0,0,0,0,194,198,12,24,48,96,198,134,0,0,0,0,

0,0,56,108,108,56,118,220,204,204,204,118,0,0,0,0,

0,48,48,48,96,0,0,0,0,0,0,0,0,0,0,0,

0,0,12,24,48,48,48,48,48,48,24,12,0,0,0,0,

0,0,48,24,12,12,12,12,12,12,24,48,0,0,0,0,

0,0,0,0,0,102,60,255,60,102,0,0,0,0,0,0,

0,0,0,0,0,24,24,126,24,24,0,0,0,0,0,0,

0,0,0,0,0,0,0,0,0,24,24,24,48,0,0,0,

0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,

0,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,

0,0,0,0,2,6,12,24,48,96,192,128,0,0,0,0,

0,0,56,108,198,198,214,214,198,198,108,56,0,0,0,0,

0,0,24,56,120,24,24,24,24,24,24,126,0,0,0,0,

0,0,124,198,6,12,24,48,96,192,198,254,0,0,0,0,

0,0,124,198,6,6,60,6,6,6,198,124,0,0,0,0,

0,0,12,28,60,108,204,254,12,12,12,30,0,0,0,0,

0,0,254,192,192,192,252,6,6,6,198,124,0,0,0,0,

0,0,56,96,192,192,252,198,198,198,198,124,0,0,0,0,

0,0,254,198,6,6,12,24,48,48,48,48,0,0,0,0,

0,0,124,198,198,198,124,198,198,198,198,124,0,0,0,0,

0,0,124,198,198,198,126,6,6,6,12,120,0,0,0,0,

0,0,0,0,24,24,0,0,0,24,24,0,0,0,0,0,

0,0,0,0,24,24,0,0,0,24,24,48,0,0,0,0,

文章来源于:电子工程世界    原文链接 本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。


登录icspec成功后,会自动跳转查看全文
博客评论
还没有人评论,赶紧抢个沙发~
发表评论
说明:请文明发言,共建和谐网络,您的个人信息不会被公开显示。