新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 最后算是搞定12232單片機(jī)驅(qū)動(dòng)了

最后算是搞定12232單片機(jī)驅(qū)動(dòng)了

作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 收藏
BYTE Read_Status(BOOL right){BYTE tData;DATA=0xff;LCD_WR=1;LCD_RD=0;A0=0;if(right){E1=0;}else{E2=0;}tData=DATA;if(right){E1=1;}else{E2=1;}LCD_RD=1;A0=1;return tData;}void LCD_Write(BOOL right,BOOL disp,BYTE Data){//模擬8080/*BYTE rTemp=0xff;while(rTemp & 0x7F){rTemp=Read_Status(right);}*/if(right){E1=0;}else{E2=0;}A0=disp;//disp=1數(shù)據(jù),disp=0顯示DATA=Data;LCD_RD=1;LCD_WR=0;__asmNOPNOPNOPNOP__endasm;LCD_WR=1;if(right){E1=1;}else{E2=1;}__asmNOPNOPNOPNOPNOPNOPNOPNOPNOPNOP__endasm;}BYTE LCD_Read(BOOL right){//模擬8080BYTE tData;if(right){E1=0;}else{E2=0;}DATA=0xFF;LCD_WR=1;LCD_RD=0;tData=DATA;LCD_RD=1;if(right){E1=1;}else{E2=1;}return tData;}void SetPage(BYTE page0,BYTE page1){LCD_Write(0,0,0xB8|page1);LCD_Write(1,0,0xB8|page0);}void SetAddress(BYTE address0,BYTE address1){LCD_Write(0,0,address1);LCD_Write(1,0,address0);}void LCD_Cls(BYTE FILL){BYTE i;BYTE page;for (page=0;page<4;page++){SetPage(page,page);SetAddress(0,0);for (i=0;i<61;i++){Both_Write_Data(FILL);}}}void Init_LCD(){RESET=1;RESET=0;//8080時(shí)序#ifdef DEBUGprintf("Status(Chip1):0x%X",Read_Status(0));printf("Status(Chip2):0x%X",Read_Status(1));#endifBoth_Write_Cmd(LCD_RESET);//軟復(fù)位#ifdef DEBUGprintf("Status(Chip1):0x%X",Read_Status(0));printf("Status(Chip2):0x%X",Read_Status(1));#endifBoth_Write_Cmd(LCD_PS_OFF);//正常驅(qū)動(dòng)Both_Write_Cmd(LCD_DISPLAY_ON);//開(kāi)顯示Both_Write_Cmd(LCD_DUTY16);//16%占空比#ifdef DEBUGprintf("Status(Chip1):0x%X",Read_Status(0));printf("Status(Chip2):0x%X",Read_Status(1));#endif}/** CODE: A0 /RD /WR D7 D6 D5 D4 D3 D2 D1 D0L L H BUSY ADC ON/OFF RESET LLLL*/void Draw8(BOOL right,BYTE Asc){BYTE i;for(i=0;i<8;i++){LCD_Write(right,1,ASCII[Asc-32][i]);}}void DrawASCIIStr(BOOL right,BYTE *str){while(*str!=