|
|||||||||||
| 技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測(cè)控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng) 驅(qū)動(dòng)編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計(jì) | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe |
hd44780驅(qū)動(dòng) |
| 作者:stering 欄目:ARM技術(shù) |
我從proteus里面改的用來(lái)學(xué)習(xí)c51.上次貼了一個(gè)程序。高手說(shuō)是用c編的匯編。-_-!,hehe.回去努力看別人程序。不止這次是不是還是匯編。^_^ //HD44780 LCD DRIVER #include "AT89X52.H" //LCD Commands #define LCD_CLS 1 //Clears entire DISPLAY and sets DDRAM address 0 #define LCD_HOME 2 //Sets DDRAM address 0 in address counter. #define LCD_SETMODE 4 //Sets cursor move direction and specifies DISPLAY shift. #define LCD_SETVISIBLE 8 //Sets entire DISPLAY (D) on/off,cursor on/off (C), and blinking of cursor position CHARacter (B). #define LCD_SHIFT 16 //Moves cursor and shifts DISPLAY without changing DDRAM contents. #define LCD_SETFUNCTION 32 //Sets interface data length (DL), NUMBER of DISPLAY lines (N), and CHARacter font (F). #define LCD_SETCGADDR 64 //Sets CGRAM address.CGRAM data is sent and received after this setting. #define LCD_SETDDADDR 128 //Sets DDRAM address. DDRAM data is sent and received after this setting. #define TURE 1 #define FORSE 0 #define TMH 0xf8 //delay timeh 2ms #define TML 0xCD //delay timel unsigned CHAR code text[6]="hellow"; static unsigned CHAR data counter; void wcCHAR(unsigned CHAR d); //write a command CHAR void DISPLAY(unsigned CHAR i); //write a data CHAR CHAR wtbusy(); //wait busy sign void clrscr(void); //clear screen void initime0(void); //initial time0 void delay(); //delay void ISR_Timer0(void) interrupt 1 { TL0=TML; TH0=TMH; counter--; } //main program DISPLAY "hellow" main(void) { unsigned CHAR data k; initime0(); wcCHAR(0x38); //initial lcd wcCHAR(LCD_SETVISIBLE+6); //set lcd visible clrscr(); //clear lcd while(1) { for(k=0;k<=6;k++) { DISPLAY(text[k]); //DISPLAY "hellow" P1_2=TURE; //TEST code ,not effective counter=200; delay(); //delay P1_2=FORSE; //TEST code ,not effective counter=200; //delay delay(); } } } //sub function || DISPLAY a CHAR void DISPLAY(unsigned CHAR i) //write a CHAR { unsigned CHAR xdata j; P1_0=FORSE; P1_1=TURE; j=i; while (wtbusy()) {} } void wcCHAR(unsigned CHAR d) //write a command CHAR { unsigned CHAR xdata j; P1_0=FORSE; P1_1=FORSE; j=d; while (wtbusy()) {} } CHAR wtbusy() //wait busy sign { unsigned CHAR xdata j; P1_0=TURE; P1_1=FORSE; if(j^128) return FORSE; else return TURE; } //clear screen void clrscr() { wcCHAR(LCD_CLS); } //initial time0 void initime0() { TL0=TML; TH0=TMH; TR0=TURE; IE=0x93; //Enable T0 and Serial PORT. } //sub function time delay void delay() { while (counter) {} }
|
|
|
| 免費(fèi)注冊(cè)為維庫(kù)電子開(kāi)發(fā)網(wǎng)會(huì)員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號(hào) |