Import-Script
12.10.2003, 16:38
Hallo! <BR> <BR>Um mich mit LCD-Modulen vertraut zu machen, habe ich mir ein zweizeiliges LCD-Modul gekauft. Nach einigem erfolglosen Probieren habe ich es dank einer PDF-Datei aus dem Internet im 8-Bit-Modus zum Funktionieren gebracht. <BR>Nun brauche ich in einer Anwendung ein 16x4-Modul - also habe ich mir eines von der Firma PicVue gekauft. Im Datenblatt steht nichts über die Ansteuerung und die Ein- und Ausgänge sind die gleichen wie beim Probiermodul, also habe ich es gleich angesteuert wie das Probiermodul - hat aber nicht funktioniert. Was gibt es da noch zu beachten? Hier das C-Programm für den Mikrocontroller: <BR>An P1 hängen die acht Datenleitungen, an Pin_E die E-Leitung, an Pin_RS die RS-Leitung und an Pin_RW die RW-Leitung. <BR> <BR>#include <AT89x051.H> <BR>#include <intrins.h> <BR> <BR>const char EURO[] = {0x07, 0x08, 0x1E, 0x08, 0x1E, 0x08, 0x07, 0x00}; <BR>const char FIRST_LINE[] = "Gute Pizza"; <BR>const char SECOND_LINE[] = {'1', ',', '-', '-', ' ', 0x00}; <BR> <BR>sbit Pin_E = P3^2; <BR>sbit Pin_RW = P3^3; <BR>sbit Pin_RS = P3^4; <BR> <BR>void CommandByte(void); <BR>void DataByte(void); <BR>void BusyDelay(void); <BR> <BR>unsigned int Counter; <BR>void InitWait(void); <BR>void Wait(unsigned int Duration); <BR> <BR>unsigned char i; <BR>void main(void) <BR>{ <BR> InitWait(); <BR> EA = 1; <BR> <BR> Pin_RS = 0; <BR> Pin_RW = 0; <BR> Pin_E = 1; <BR> <BR> Wait(150); <BR> P1 = 0x38; <BR> CommandByte(); <BR> Wait(41); <BR> P1 = 0x38; <BR> CommandByte(); <BR> Wait(1); <BR> P1 = 0x38; <BR> CommandByte(); <BR> P1 = 0x0C; <BR> CommandByte(); <BR> P1 = 0x01; <BR> CommandByte(); <BR> <BR> P1 = 0x40; <BR> CommandByte(); <BR> for(i = 0; i < 8; i++) <BR> { <BR> P1 = EURO[i]; <BR> DataByte(); <BR> } <BR> <BR> P1 = 0x80; <BR> CommandByte(); <BR> for(i = 0; i < 10; i++) <BR> { <BR> P1 = FIRST_LINE[i]; <BR> DataByte(); <BR> } <BR> P1 = 0xC0; <BR> CommandByte(); <BR> for(i = 0; i < 6; i++) <BR> { <BR> P1 = SECOND_LINE[i]; <BR> DataByte(); <BR> } <BR> <BR> while(1); <BR>} <BR> <BR>void CommandByte(void) <BR>{ <BR> Pin_RS = 0; <BR> _nop_(); <BR> BusyDelay(); <BR>} <BR> <BR>void DataByte(void) <BR>{ <BR> Pin_RS = 1; <BR> _nop_(); <BR> BusyDelay(); <BR>} <BR> <BR>void BusyDelay(void) <BR>{ <BR> unsigned char Busy; <BR> Pin_RW = 0; <BR> Pin_E = 0; <BR> _nop_(); <BR> Pin_E = 1; <BR> _nop_(); <BR> P1 = 0xFF; <BR> Pin_RW = 1; <BR> Pin_RS = 0; <BR> Pin_E = 0; <BR> _nop_(); <BR> Pin_E = 1; <BR> do <BR> { <BR> do <BR> { <BR> _nop_(); <BR> Busy = P1 & 0x80; <BR> } while(Busy != 0x00); <BR> Busy = P1 & 0x80; <BR> } while(Busy != 0x00); <BR> Pin_RW = 0; <BR>} <BR> <BR>void InitWait(void) <BR>{ <BR> TMOD = 0x02; // autoreload <BR> TH0 = 0x9C; // for 100 µs (at 12 MHz) <BR> TL0 = 0x9C; <BR> ET0 = 0; // enable timer 0 interrupt <BR> TR0 = 0; <BR>} <BR> <BR>void Timer0Interrupt(void) interrupt 1 <BR>{ <BR> Counter++; <BR>} <BR> <BR>void Wait(unsigned int Duration) <BR>{ <BR> Counter = 0; <BR> TR0 = 1; <BR> ET0 = 1; <BR> while(Counter < Duration); <BR> ET0 = 0; <BR> TR0 = 0; <BR>} <BR> <BR>Also: Wie bereits erwähnt - das Programm habe ich aus dem Internet und es funktioniert auf dem Probiermodul problemlos. Wieso nicht auf dem 16x4? <BR> <BR>mfg <BR>cndg