#include #define COMMAND 0x30 // 0011 0000 (ist das Initialisierungskommando => aus Datenblatt) #define BUSY 0x80 // Bit 7 (von Port 2.7 ist gesetzt, wenn Display für den Empfang // weiterer Daten noch nicht bereit ist!) #define WAIT_WHILE_BUSY { while (ReadBusyFlag() & BUSY); } // LCD-Datenpins liegen auf Port 2 // // E RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 // // P2.10 P2.8 P2.9 P7.7 P7.6 P7.5 P7.4 P7.3 P7.2 P7.1 P7.0 // sbit P70 = P7^0; sbit P71 = P7^1; sbit P72 = P7^2; sbit P73 = P7^3; sbit P74 = P7^4; sbit P75 = P7^5; sbit P76 = P7^6; sbit P77 = P7^7; sbit DP28 = DP2^8; sbit DP29 = DP2^9; sbit DP210 = DP2^10; sbit RS = P2^8; // Register Select: RS = 1: Daten werden gesendet! // RS = 0: Kommando wird gesendet! sbit RW = P2^9; // Read/Write-Pin: Read = 1 / Write = 0 sbit Enable = P2^10; // bei fallender Flanke (1->0) werden die Werte der Daten- und // Steuerleitungen vom Display eingelesen! void Wait(unsigned int i) { unsigned long a; for(a=0; a0) übernommen Wait(3000); // kurz warten Enable = 0; Wait(88000); //Warten 4,1 ms RS = 0; RW = 0; P7 = COMMAND; Enable = 1; Wait(3000); // kurz warten Enable = 0; Wait(3000); // 100 us warten RS = 0; RW = 0; P7 = COMMAND; Enable = 1; Wait(3000); // kurz warten Enable = 0; Wait(3000); // 100 us warten // Display-Mode festlegen RS = 0; RW = 0; P7 = 0x38; // 00111000 Enable = 1; // ||| Wait(310000); // ||\- Zeichenfont 5x7 Enable = 0; // |\-- 2 Zeilen // \--- 8-Bit Mode Wait(310000); // ab hier kann das Busy-Flag abgefragt werden! // Display einschalten RS = 0; RW = 0; P7 = 0x3f; // 00111111 Enable = 1; // ||| Wait(310000); // || \- Zeichen unter dem Cursor blinkt Enable = 0; // | \-- Cursor sichtbar // \--- Display einschalten Wait(310000); WAIT_WHILE_BUSY; // warten, bis Busy-Flag vom Displaycontroller gelöscht wird // Display löschen RS = 0; RW = 0; P7 = 0x01; // Kommando "Display löschen" Enable = 1; Wait(310000); Enable = 0; Wait(310000); WAIT_WHILE_BUSY; // Entry Mode Set RS = 0; RW = 0; P7 = 0x06; // 00000110 Enable = 1; // || Wait(310000); // |\- Displayinhalt nicht schieben Enable = 0; // \-- Adresspointer inkrementieren Wait(310000); } void main (void) { DP7=0xff; DP28 = 1; DP29 = 1; DP210 = 1; Enable = 0; RS =0; RW =0; InitLCD(); do{ WriteChar('S'); //WriteText ("Test und Noch mal"); }while(1); }