TIM圖片20200303161855.png (98.49 KB, 下載次數(shù): 43)
下載附件
2020-3-3 16:27 上傳
TIM圖片20200303162236.png (20.68 KB, 下載次數(shù): 52)
下載附件
2020-3-3 16:27 上傳
根據(jù)lab8000用proteus仿真的 剛剛接觸這個(gè)LCD,可能連線不對(duì),單片機(jī)代碼如下
- #include<reg51.h>
- #define PD1 61
- unsigned char Column;
- unsigned char Page_;
- unsigned char Code_;
- unsigned char Command;
- unsigned char LCDData;
- xdata unsigned char CWADD1 _at_ 0x8000;
- xdata unsigned char DWADD1 _at_ 0x8001;
- xdata unsigned char CRADD1 _at_ 0x8002;
- xdata unsigned char DRADD1 _at_ 0x8003;
- xdata unsigned char CWADD2 _at_ 0x8004;
- xdata unsigned char DWADD2 _at_ 0x8005;
- xdata unsigned char CRADD2 _at_ 0x8006;
- xdata unsigned char DRADD2 _at_ 0x8007;
- code unsigned char EETAB[ ][8]={
- {0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x00},
- {0x10,0x30,0x50,0x10,0x10,0x10,0x7c,0x00},
- {0x38,0x44,0x04,0x08,0x10,0x20,0x7c,0x00},
- {0x78,0x84,0x04,0x38,0x04,0x84,0x78,0x00}
- };
- code unsigned char CCTAB[][32] ={
- {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
- 0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
- 0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
- 0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00},
- {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
- 0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
- 0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
- 0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00},
- {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
- 0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
- 0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
- 0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00},
- {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
- 0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
- 0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
- 0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00}
- };
- void WriteCommandE1(){
- while(CRADD1 & 0x80);
- CWADD1 = Command;
- }
- void WriteDataE1(){
- while(CRADD1 & 0x80);
- DWADD1 = LCDData;
- }
- void ReadDataE1(){
- while(CRADD1 & 0x80);
- LCDData = DRADD1;
- }
- void WriteCommandE2(){
- while(CRADD2 & 0x80);
- CWADD2 = Command;
- }
- void WriteDataE2(){
- while(CRADD2 & 0x80);
- DWADD2 = LCDData;
- }
- void ReadDataE2(){
- while(CRADD2 & 0x80);
- LCDData = DRADD2;
- }
- void Init(){
- Command = 0xe2;
- WriteCommandE1();
- WriteCommandE2();
- Command = 0xa4;
- WriteCommandE1();
- WriteCommandE2();
- Command = 0xa9;
- WriteCommandE1();
- WriteCommandE2();
- Command = 0xa0;
- WriteCommandE1();
- WriteCommandE2();
- Command = 0xc0;
- WriteCommandE1();
- WriteCommandE2();
- Command = 0xaf;
- WriteCommandE1();
- WriteCommandE2();
- }
- void Clear(){
- unsigned char i, j;
- i = 0;
- do{
- Command = (i + 0xb8);
- WriteCommandE1();
- WriteCommandE2();
- Command = 0x00;
- WriteCommandE1();
- WriteCommandE2();
- j = 0x50;
- do{
- LCDData = 0x00;
- WriteDataE1();
- WriteDataE2();
- }while(--j!=0);
- }while(++i!=4);
- }
- void Delay(){
- unsigned char i, j;
- i = 20;
- j = 0;
- do{
- do{
- }while(--j!=0);
- }while(--i!=0);
- }
- void WriteCHN16x16(){
- unsigned char i, j, k;
- i = 0;
- j = 0;
- while(j<2){
- Command = ((Page_ + j) & 0x03)|0xb8;
- WriteCommandE1();
- WriteCommandE2();
- k = Column;
- while(k < Column + 16){
- if(k < PD1){
- Command = k;
- WriteCommandE1();
- LCDData = CCTAB[Code_][i];
- WriteDataE1();
- }
- else{
- Command = k-PD1;
- WriteCommandE2();
- LCDData = CCTAB[Code_][/i][i][i];
- WriteDataE2();
- }
- i++;
- if(++k >= PD1*2) break;
- }
- j++;
- }
- }
- void main(){
- Init();
- Clear();
- Page_ = 0x02;
- Column = 0x00;
- Code_ = 0x00;
- WriteCHN16x16();
- while(1);
- }
復(fù)制代碼
|