|
發(fā)布時間: 2019-1-27 20:57
正文摘要:我這個LCD12864在proteus上面仿真是可以顯示的,但是實際上接好線,同樣的代碼,就是只有藍色底(連背光也沒有),接線是沒有問題的,大家覺得問題可能出現(xiàn)在哪里 |
| 對比度控制部分電路怎么處理的? |
|
LCD12864仿真與現(xiàn)實用的LCD12864沒有那一款是相同的,所以不能用仿真的代碼驅動現(xiàn)實的LCD,你應該將你的LCD圖片傳上來讓大家看看你用的是哪種(現(xiàn)實板的也有很大的不同,有有字庫與無字庫,驅動用的芯片也有很多不一樣的) 我這有一個 #include<reg51.h> #define uint unsigned int #define uchar unsigned char sbit RS = P2^6; //(數(shù)據(jù)命令)寄存器選擇輸入 sbit RW = P2^5; //液晶讀/寫控制 sbit EN = P2^7; //液晶使能控制 sbit PSB = P3^2; //串/并方式控制 sbit RST = P3^4; //復位端 void LCD12864_init(); void delay(uint c); uchar Busy(void); //判忙 void WriteCmd(uchar cmd); //寫指令 void WriteData(uchar dat); //寫數(shù)據(jù) void SetWindow(uchar x, uchar y); // SetWindow void disp(uchar *wc); //顯示 uchar code zhifu1[]="相見時難別亦難,東風無力百花殘。春蠶到死絲方盡,蠟炬成灰淚始干。0 "; uchar code zhifu2[]="曉鏡但愁云鬢改,夜吟應覺月光寒。蓬山此去無多路,青鳥殷勤為探看。0 "; uchar code shiju1[]="黃河遠上白云間,一片孤城萬仞山。羌笛何須怨楊柳,春風不度玉門關。0 "; uchar code shiju2[]="兩個黃鸝鳴翠柳,一行白鷺上青天。窗含西嶺千秋雪,門泊東吳萬里船。0 "; uchar code shiju3[]=" 千山鳥飛絕, 萬徑人蹤滅。 孤舟蓑笠翁, 獨釣寒江雪。 0 "; uchar code ci1[]="春花秋月何時了?往事知多少。 小樓昨夜又東風,故國不堪回首 0 "; uchar code ci2[]="月明中。 雕欄玉砌應猶在,只是朱顏改。 問ju能有幾多愁?0 ";// 我暈!沒有君! uchar code ci3[]="恰似一江春水 向東流。 0 "; uchar code zhaopin1[]=" 【招聘】 電子軟件工程師: 1 名 1.要會吹牛 0 "; uchar code zhaopin2[]="2.要會勾妹仔, 多勾多得! 3.要會忽悠 趙本山十級俱佳。0 "; void disp(uchar *wc) { uchar t; t=0; SetWindow(0, 0); while(wc[t]!='\0') { WriteData(wc[t]); t++; if (t==16)SetWindow(1,0); //第一行滿寫第三行 if (t==32)SetWindow(2,0); //第三行滿寫第四行 if (t==48)SetWindow(3,0); //第三行滿寫第四行 } delay(5000); } void main() { uchar j=0; LCD12864_init(); while(1) { disp(&zhifu1); disp(&zhifu2); disp(&shiju1); disp(&shiju2); disp(&shiju3); disp(&ci1); disp(&ci2); disp(&ci3); disp(&zhaopin1); disp(&zhaopin2); } } void LCD12864_init() //初始化LCD12864 { PSB = 1; //選擇并行輸入 RST = 1; //復位 WriteCmd(0x30); //選擇基本指令操作 WriteCmd(0x0c); //顯示開,關光標 WriteCmd(0x01); //清除LCD12864的顯示內容 } void delay(uint c) { uchar a,b; for(; c>0; c--) { for(b=199; b>0; b--) { for(a=1; a>0; a--); } } } uchar Busy(void) //判忙 { uchar i = 0; RS = 0; //選擇命令 RW = 1; //選擇讀取 EN = 1; delay(1); while(( P0 & 0x80) == 0x80) //檢測讀取到的值 { i++; if(i > 100) { EN = 0; return 0; //超過等待時間返回0表示失敗 } } EN = 0; return 1; } void WriteCmd(uchar cmd) //寫指令 { uchar i; i = 0; while( Busy() == 0) { delay(1); i++; if( i>100) { return; //超過等待退出 } } RS = 0; //選擇命令 RW = 0; //選擇寫入 EN = 0; //初始化使能端 P0 = cmd; //放置數(shù)據(jù) EN = 1; //寫時序 delay(5); EN = 0; } void WriteData(uchar dat) //寫數(shù)據(jù) { uchar i = 0; while( Busy() == 0) { delay(1); i++; if( i>100)return;//超過等待退出 } RS = 1; //選擇數(shù)據(jù) RW = 0; //選擇寫入 EN = 0; //初始化使能端 P0 = dat; //放置數(shù)據(jù) EN = 1; //寫時序 delay(5); EN = 0; } void SetWindow(uchar x, uchar y) // SetWindow { uchar con; if(x == 0) x = 0x80; // 第一行的地址是80H else if(x == 1) x = 0x90; // 第二行的地址是90H else if(x == 2) x = 0x88; // 第三行的地址是88H else if(x == 3) x = 0x98; // 98 con = x + y; WriteCmd(con); } 這幾點控制點你要改成你板上的,數(shù)據(jù)口也要改 sbit RS = P2^6; //(數(shù)據(jù)命令)寄存器選擇輸入 sbit RW = P2^5; //液晶讀/寫控制 sbit EN = P2^7; //液晶使能控制 sbit PSB = P3^2; //串/并方式控制 sbit RST = P3^4; //復位端 下面是我用的12864帶字庫
|
| 參與人數(shù) 7 | 黑幣 +108 | 收起 理由 |
|---|---|---|
|
| + 12 | |
|
| + 12 | |
|
| + 12 | |
|
| + 12 | |
|
| + 35 | |
|
| + 15 | 回帖助人的獎勵! |
|
| + 10 | 回帖助人的獎勵! |
Powered by 單片機教程網(wǎng)