Hallo,
ich habe mir vom MSC Elekronic einen Beispielcode für die Ansteuerung eines LCD Displays (4*20) besorgt.
Leider bekomme ich es nicht zu laufen. Kennt ihr das Problem?
Ich habe den Code, den ich etwas modifizieren musste mal angehängt:
Code:'LCD Testanzeige $regfile = "m8def.dat" $crystal = 7372800 $baud = 4800 Config Lcd = 20 * 4 'LCD-Display mit 20 Zeichen in 4 Zeilen verwendet Config Lcdbus = 4 '4 bit mode Config Lcdmode = Port Config Lcdpin = Pin , Db4 = Portc.1 , Db5 = Portc.2 , Db6 = Portc.3 , Db7 = Portc.4 , E = Portc.5 , Rs = Portd.6 'war Portc.6 Deflcdchar 0 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32 Deflcdchar 1 , 10 , 32 , 14 , 17 , 17 , 17 , 14 , 32 Dim A As Byte Cls 'clear the LCD display Lcd "Hello world." 'display this at the top line Wait 1 Lowerline 'select the lower line Wait 1 Lcd "Shift this." 'display this at the lower line Wait 1 For A = 1 To 10 Shiftlcd Right 'shift the text to the right Wait 1 'wait a moment Next For A = 1 To 10 Shiftlcd Left 'shift the text to the left Wait 1 'wait a moment Next Locate 2 , 1 'set cursor position Lcd "*" 'display this Wait 1 'wait a moment Shiftcursor Right 'shift the cursor Lcd "@" 'display this Wait 1 'wait a moment Home Upper 'select line 1 and return home Lcd "Replaced." 'replace the text Wait 1 'wait a moment Cursor Off Noblink 'hide cursor Wait 1 'wait a moment Cursor On Blink 'show cursor Wait 1 'wait a moment Display Off 'turn display off Wait 1 'wait a moment Display On 'turn display on '-----------------NEW support for 4-line LCD------ Thirdline Lcd "Line 3" Fourthline Lcd "Line 4" Home Third 'goto home on line three Home Fourth Home F 'first letteer also works Locate 4 , 1 : Lcd "Line 4" Wait 1 Deflcdchar 1 , 225 , 227 , 226 , 226 , 226 , 242 , 234 , 228 ' replace ? with number (0-7) Deflcdchar 0 , 240 , 224 , 224 , 255 , 254 , 252 , 248 , 240 ' replace ? with number (0-7) Cls 'select data RAM Rem it is important that a CLS is following the deflcdchar statements because it will set the controller back in datamode Lcd Chr(0) ; Chr(1) 'print the special character '----------------- Now use an internal routine ------------ _temp1 = 1 'value into ACC !rCall _write_lcd 'put it on LCD End







					
					
					
						
Zitieren


Lesezeichen