#includestc89.h>#includeintrins.h>#define uchar unsigned char#define uint unsigned intuint ee;sbit lcd_cs3=P1^0;//片選信號(hào)右 低有效sbit lcd_cs2=P1^1;//片選信號(hào)中 低有效sbit lcd_cs1=P1^2;//片選信號(hào)左 低有效sbit lcd_e =P1^3;//使能信號(hào)sbit lcd_rw =P1^4;//讀寫選擇sbit lcd_rs =P1^5;//數(shù)據(jù)命令選擇端 H數(shù)據(jù) L命令//P2八位數(shù)據(jù)線uchar code cc[]={0x00,0x00,0x00,0x00,0x01,0x06,0x00,0x00,0x00,0xFF,0x00,0x00,0x04,0x02,0x01,0x00,0x00,0x00,0x20,0x40,0x80,0x00,0x00,0x02,0x01,0xFE,0x00,0x00,0x00,
0x00,0x80,0xE0};void lcd_init();void wrile_com(uchar com);void wrile_data(uchar dat);void delay(uchar d0);void main(){lcd_cs1=0;lcd_cs2=0;lcd_cs3=0;lcd_init();wrile_data(0x11);wrile_data(0x0a);
wrile_data(0x04);wrile_data(0x0a);
wrile_data(0x11);wrile_data(0x00);wrile_data(0x1f);wrile_data(0x05);
wrile_data(0x05);wrile_data(0x05);
wrile_data(0x02);wrile_data(0x00);wrile_data(0x11);wrile_data(0x0a);
wrile_data(0x04);wrile_data(0x0a);
wrile_data(0x11);wrile_data(0x00);wrile_data(0x1f);wrile_data(0x05);
wrile_data(0x05);wrile_data(0x05);
wrile_data(0x02);wrile_data(0x00);while(1);}void lcd_init(){delay(255);//等待復(fù)位wrile_com(0x3f);wrile_com(0xc0); wrile_com(0xbc);//頁地址 wrile_com(0x40); }void wrile_com(uchar com){ lcd_e=0; //lcd_rw=0;//讀寫選擇 寫lcd_rs=0;//數(shù)據(jù)命令 命令lcd_e=1; //P2=com;_nop_();lcd_e=0;delay(5);}void wrile_data(uchar dat){ lcd_e=0; //lcd_rw=0;//讀寫選擇 寫lcd_rs=1;//數(shù)據(jù)命令 命令lcd_e=1; //P2=dat;_nop_();lcd_e=0;delay(5);}void delay(uchar d0){uchar d1,d2;for(d1=d0;d1>0;d1--)for(d2=110;d2>0;d2--);}
評(píng)論