T6963c液晶驱动芯片
时间:08-04
来源:互联网
点击:
/***********************************************名称 :带T6963C 控制器液晶驱动模块设计者:阿飞时间:dec.09.10版本:vec1**************************************************/#include"reg51.h"#include"zifu.h"#define uchar unsigned char#define uint unsigned int#define lcd_data P1#define lcd_com P2extern void write_clcd_two(uchar dat1,uchar dat2,uchar com); extern void write_clcd_one(uchar dat1,uchar com);extern void write_clcd(uchar com);extern write_dlcd(uchar dat);extern uchar read_ddata();/******sbit rd=lcd_com^0; sbit wr=lcd_com^1;sbit cd=lcd_com^2; sbit ce=lcd_com^3;**************//**指令格式 参数1 参数2 指令代码 *//**读lcd状态字节 state***/uchar read_flag_lcd() {uchar dat;lcd_com=0x06;dat=lcd_data;lcd_com=0x0f;return dat;}/****检查lcd状态字state 0,1位是否为1,1表示lcd已准备好*****/void check0_1(){uchar dat;dat=read_flag_lcd() ;while(dat0x03!=0x03);}/****检查lcd状态字state 第2位是否为1,1表示lcd数据自动读操作已准备好*****/void check2(){uchar dat;dat=read_flag_lcd() ;while(dat0x04!=0x03);}/****检查lcd状态字state 第2位是否为1,1表示lcd数据自动写操作已准备好*****/void check3(){uchar dat;dat=read_flag_lcd() ;while(dat0x08!=0x08);}/****检查lcd状态字state 第6位是否为1,1屏读/拷贝出错状态****/void check6(){uchar dat;dat=read_flag_lcd() ;while(dat0x40!=0x40);}/****写命令字data1 data2 为参数 com为命令字节*****/void write_clcd_two(uchar dat1,uchar dat2,uchar com){check0_1();lcd_com=0x01;lcd_data=dat1;lcd_com=0x0f;check0_1();lcd_com=0x01;lcd_data=dat2;lcd_com=0x0f;check0_1();lcd_com=0x05;lcd_data=com;lcd_com=0x0f;}/****写命令字data1为参数 com为命令字节*****/void write_clcd_one(uchar dat1,uchar com){check0_1();lcd_com=0x01;lcd_data=dat1;lcd_com=0x0f;check0_1();lcd_com=0x05;lcd_data=com;lcd_com=0x0f;}/****无参数 com为命令字节*****/void write_clcd(uchar com){check0_1();lcd_com=0x05;lcd_data=com;lcd_com=0x0f;}/****读数据 data*****/uchar read_ddata(){uchar dat;check0_1();lcd_com=0x02;dat=lcd_data;lcd_com=0x0f;return dat;}/****写数据 data*****/write_dlcd(uchar dat){check0_1();lcd_com=0x01;lcd_data=dat;lcd_com=0x0f;}lcd_clr(){uint n;write_clcd_two(0x00,0x00,0x24);write_clcd(0xb0);for(n=0;n480;n++)write_dlcd(0x00);write_clcd(0xb2);}void word_16(uchar row ,uchar list, uchar *pdat){uchar addr_h,addr_l,n;uint p_addr;if(row>29){list=list+(row/30)4;row=row%30;}for(n=0;n16;n++){p_addr=(list+n)*30+row;addr_h=p_addr>>8;addr_l=p_addr%256;write_clcd_two(addr_l,addr_h,0x24);write_clcd(0xb0);check3();write_dlcd(*(pdat+2*n));check3();write_dlcd(*(pdat+2*n+1));write_clcd(0xb2);}}void word_8(uchar row ,uchar list, uchar *pdat){uchar addr_h,addr_l,n;uint p_addr;for(n=0;n16;n++){p_addr=(list+n)*30+row;addr_h=p_addr>>8;addr_l=p_addr%256;write_clcd_two(addr_l,addr_h,0x24);write_clcd(0xb0);check3();write_dlcd(*(pdat+n));write_clcd(0xb2);}}lcd_init(){//显示区域设置指令格式为:D1低 D2高 0 1 0 0 0 0 n1 n0write_clcd_two(0x00,0x00,0x40);//文本区首地址 0x0000write_clcd_two(0x1e,0x00,0x41);//文本区屏宽字节数 0x1e =30 *8bit//write_clcd_two(0x00,0x00,0x42);// 设置图形显示区域首地址//write_clcd_two(0x1e,0x00,0x43);// 图形区屏宽字节数write_clcd(0xa0);//光标形状设置 1 0 1 0 0 N2 N1 N0 光标高度write_clcd(0x9d);//显示开关 1 0 0 1 N3 N2 N1 N0 N0:1/0,光标闪烁启用/禁止N1:1/0,光标显示启用/禁止N2:1/0,文本显示启用/禁止N3:1/0,图形显示启用/禁止write_clcd(0x80);//显示方式设置,逻辑"或"合成}user_letter(uchar row ,uchar list, uchar *pdat ){uchar addr_h,addr_l;uint p_addr,n;if(row>29){list=list+(row/30)4;row=row%30;}p_addr=list*30+row;addr_h=p_addr>>8;addr_l=p_addr%256;write_clcd_two( addr_l, addr_h,0x24);write_clcd(0xb0);for(n=0;n3840-p_addr;n++)///////////////////////////////{check3();write_dlcd(*(pdat+n));}write_clcd(0xb2);}void delay(int z) {int x,y;for(x=z;x>0;x--)for(y=1000;y>0;y--);} main(){uchar n;lcd_init();write_clcd_two(0x00,0x00,0x24);//write_clcd_two(0x00,0x00,0x24);//user_letter(0x00 ,0x00, over1);//for(n=0;n57;n++)//word_16(0x04+2*n ,0x00, word+32*n);//delay(1000);//user_letter(0x00 ,0x40, afei);//delay(1000);//write_clcd_two(0x00,0x00,0x24);//user_letter(0x00 ,0x00, over);//write_clcd(0xb0);//数据自动读/写方式设置1 0 1 1 0 0 N1 N00 0 B0H 自动写设置0 1 B1H 自动读设置1 * B2H/B3H 自动读/写结束//for(n=0;n150;n++)//{//check3();//write_dlcd(0x12);//}//write_clcd(0xb2);write_clcd_one(0x03,0xc4);write_clcd_two(0x1f,0x0f,0x21);write_dlcd(0xf0);while(1){};}
- T6963C的51单片机驱动程序(12-02)
- LCD 240*128 T6963C C51程序(12-02)
- 内藏T6963C控制器的液晶模块的显示(11-10)
- 基于T6963C控制器的液晶模块显示技术(10-09)
- 基于51单片机和FPGA的人机交互系统的设计(11-16)
- 基于ARM9&Linux的液晶驱动终端设计(04-30)