$LCD/de

(Difference between revisions)
Jump to: navigation, search
m (1 revision)
(Example)
Line 55: Line 55:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Example</span> =
+
= <span class="f_Header">Beispiel</span> =
  
 
<br/><source lang="bascomavr">
 
<br/><source lang="bascomavr">
'--------------------------------------------------------------
+
'-----------------------------------------------------------------------------------------
' (c) 1995-2005 MCS Electronics
+
'name : lcd.bas
'--------------------------------------------------------------
+
'copyright : (c) 1995-2005, MCS Electronics
' file: LCD.BAS
+
'purpose : demo: LCD, CLS, LOWERLINE, SHIFTLCD, SHIFTCURSOR, HOME
' demo: LCD, CLS, LOWERLINE, SHIFTLCD, SHIFTCURSOR, HOME
+
 
' CURSOR, DISPLAY
 
' CURSOR, DISPLAY
'--------------------------------------------------------------
+
'micro : Mega8515
 +
'suited for demo : yes
 +
'commercial addon needed : no
 +
'-----------------------------------------------------------------------------------------
 
   
 
   
'note : tested in bus mode with 4-bit on the STK200
+
$regfile = "m8515.dat" ' Benutzter Mikrocontroller
'LCD - STK200
+
$crystal = 4000000 ' Taktfrequenz
'-------------------
+
$baud = 19200 ' Baudrate
'D4 D4
+
$hwstack = 32 ' default use 32 for the hardware stack
'D5 D5
+
$swstack = 10 ' default use 10 for the SW stack
'D6 D6
+
$framesize = 40 ' default use 40 for the frame space
'D7 D7
+
'WR WR
+
'E E
+
'RS RS
+
'+5V +5V
+
'GND GND
+
'V0 V0
+
' D0-D3 are not connected since 4 bit bus mode is used!
+
 
   
 
   
 +
 +
$sim
 +
'Entfernen Sie &&SIM wenn das Programm gebrannt werden soll !!
 +
'$sim wird für eine schnellere Simulation verwendet.
 +
 +
 +
'Anmerkung: Getestet mit PIN Mode mit 4-bit
 
   
 
   
 
'Config Lcdpin = Pin , Db4 = Portb.1 , Db5 = Portb.2 , Db6 = Portb.3 , Db7 = Portb.4 , E = Portb.5 , Rs = Portb.6
 
'Config Lcdpin = Pin , Db4 = Portb.1 , Db5 = Portb.2 , Db6 = Portb.3 , Db7 = Portb.4 , E = Portb.5 , Rs = Portb.6
Rem with the config lcdpin statement you can override the compiler settings
+
Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Portc.7 , Rs = Portc.6
 +
'Settings für ein STK200 in PIN Mode
 +
'Verbinden Sie DB4 bis DB7 des LCD mit dem LCD Anschluss des STK D4-D7
 +
'Verbinden Sie E des LCD mit A15 (PORTC.7) und NICHT mit E des LCD Anschlusses
 +
'Vervinden Sie RS, V0, GND und =5V des LCD mit dem STK LCD Anschluss
 +
 +
Rem Mit dem config lcdpin Befehl kann man die Stanfardwerte überschreiben
 
   
 
   
$regfile = "8515def.dat"
 
$lcd = &HC000
 
$lcdrs = &H8000
 
Config Lcdbus = 4
 
 
   
 
   
 
Dim A As Byte
 
Dim A As Byte
Config Lcd = 16 * 2 'configure lcd screen
+
Config Lcd = 16 * 2 'Konfigurieren des LC Displays.
'other options are 16 * 2 , 16 * 4 and 20 * 4, 20 * 2 , 16 * 1a
+
'When you dont include this option 16 * 2 is assumed
+
'16 * 1a is intended for 16 character displays with split addresses over 2 lines
+
 
   
 
   
'$LCD = address will turn LCD into 8-bit databus mode
 
' use this with uP with external RAM and/or ROM
 
' because it aint need the port pins !
 
 
   
 
   
Cls 'clear the LCD display
+
'Andere Optionen sind 16 * 4 and 20 * 4, 20 * 2 , 16 * 1a
Lcd "Hello world." 'display this at the top line
+
'Wenn nichts angegeben wird dann wird 16 * 2 angenommen
 +
'16 * 1a wird benutzt für 16-Zeichen Displays mit über 2 Zeilen verteilten Adressen
 +
 +
'$LCD = address    Setzt das LC-Display in 8-Bit Mode
 +
' Benutzen Sie das für uP mit externem RAM und/oder ROM
 +
' weil die nicht die Portpins benutzen
 +
 +
Cls 'Löschen des LCD Displays
 +
Lcd "Hello world." 'Anzeigen des Textes in der ersten Zeile
 
Wait 1
 
Wait 1
Lowerline 'select the lower line
+
Lowerline 'Positionieren auf die unterste Zeile
 
Wait 1
 
Wait 1
Lcd "Shift this." 'display this at the lower line
+
Lcd "Shift this." 'Anzeigen in unterster Zeile
 
Wait 1
 
Wait 1
 
For A = 1 To 10
 
For A = 1 To 10
Shiftlcd Right 'shift the text to the right
+
Shiftlcd Right 'Text nach rechts verschieben
Wait 1 'wait a moment
+
Wait 1 'Etwas warten
 
Next
 
Next
 
   
 
   
 
For A = 1 To 10
 
For A = 1 To 10
Shiftlcd Left 'shift the text to the left
+
Shiftlcd Left 'Text nach links verschieben
Wait 1 'wait a moment
+
Wait 1 'Einen Moment warten
 
Next
 
Next
 
   
 
   
Locate 2 , 1 'set cursor position
+
Locate 2 , 1 'Schreibmarke setzen
Lcd "*" 'display this
+
Lcd "*" 'Zeichen anzeigen
Wait 1 'wait a moment
+
Wait 1 'warten
 
   
 
   
Shiftcursor Right 'shift the cursor
+
Shiftcursor Right 'Schreibmnarke verschieben
Lcd "@" 'display this
+
Lcd "@" 'Anzeigen
Wait 1 'wait a moment
+
Wait 1 'warten
 
   
 
   
Home Upper 'select line 1 and return home
+
Home Upper 'Obere Zeile Position 1
Lcd "Replaced." 'replace the text
+
Lcd "Replaced." 'Test anzeigen (alten überschreiben)
 
Wait 1 'wait a moment
 
Wait 1 'wait a moment
 
   
 
   
Cursor Off Noblink 'hide cursor
+
Cursor Off Noblink 'Schreibmarke nicht anzeigen
Wait 1 'wait a moment
+
Wait 1 'warten
Cursor On Blink 'show cursor
+
Cursor On Blink 'Schreibmarke wieder anzeigen
Wait 1 'wait a moment
+
Wait 1 'warten
Display Off 'turn display off
+
Display Off 'Display ausschalten
Wait 1 'wait a moment
+
Wait 1 'warten
Display On 'turn display on
+
Display On 'Display einschalten
'-----------------NEW support for 4-line LCD------
+
'-----------------Neue Unterstützung von 4-Zeilen LC-Displays------
 
Thirdline
 
Thirdline
 
Lcd "Line 3"
 
Lcd "Line 3"
 
Fourthline
 
Fourthline
 
Lcd "Line 4"
 
Lcd "Line 4"
Home Third 'goto home on line three
+
Home Third 'Gehe zu Home der dritten Zeile
 
Home Fourth
 
Home Fourth
Home F 'first letteer also works
+
Home F 'Es reicht auch der erste Buchstabe
 
Locate 4 , 1 : Lcd "Line 4"
 
Locate 4 , 1 : Lcd "Line 4"
 
Wait 1
 
Wait 1
 
   
 
   
'Now lets build a special character
+
'Definition benutzerdefinierter Zeichen
'the first number is the characternumber (0-7)
+
'Die erste Ziffer ist die Zeichennummer (0-7)
'The other numbers are the rowvalues
+
'Die anderen Zahlen sind die Zeilenwerte
'Use the LCD tool to insert this line
+
'Benutzen Sie das LCD Tool und Zeichen zu erstellen und diese Zahlen einzustellen
 
   
 
   
 
Deflcdchar 1 , 225 , 227 , 226 , 226 , 226 , 242 , 234 , 228 ' replace ? with number (0-7)
 
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)
 
Deflcdchar 0 , 240 , 224 , 224 , 255 , 254 , 252 , 248 , 240 ' replace ? with number (0-7)
Cls 'select data RAM
+
Cls 'Selektiere Daten RAM
Rem it is important that a CLS is following the deflcdchar statements because it will set the controller back in datamode
+
Rem Es ist wichtig, dass ein CLS nach den DEFLCDCHAR Befehlen kommt weil das den LCD-Controller wieder in den Datenmode zurücksetzt.
Lcd Chr(0) ; Chr(1) 'print the special character
+
Lcd Chr(0) ; Chr(1) 'Ausgabe von benutzterdefinierten Zeichen
 
   
 
   
'----------------- Now use an internal routine ------------
+
'----------------- Benutzung einer internen Routine ------------
_temp1 = 1 'value into ACC
+
_temp1 = 1 'Wert in ACC
!rCall _write_lcd 'put it on LCD
+
!rCall _write_lcd 'auf LCD schreiben
 
End
 
End
 
</source><br/>{{Languages}}
 
</source><br/>{{Languages}}
  
[[Category:BASCOM_Language_Reference/de]]
+
[[Category:BASCOM Language Reference/de]]

Revision as of 02:05, 25 February 2013

Contents

= (**COPIED FROM ENGLISH PAGE**) === Action

Instruct the compiler to generate code for 8-bit LCD displays attached to the data bus.

 

 

Syntax

$LCD = [&H]address

 

 

Remarks

Address

The address where must be written to, to enable the LCD display and the RS line of the LCD display.

 

The db0-db7 lines of the LCD must be connected to the data lines D0-D7. (or is 4 bit mode, connect only D4-D7)

The RS line of the LCD can be configured with the LCDRS statement.

 

On systems with external RAM, it makes more sense to attach the LCD to the data bus. With an address decoder, you can select the LCD display.

 

Do not confuse $LCD with the LCD statement.

The compiler will create a constant named ___LCD_ADR which you could use in an alternative LCD library.

 

 

See also

$LCDRS , CONFIG LCD

 

 

Beispiel


'-----------------------------------------------------------------------------------------
'name : lcd.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demo: LCD, CLS, LOWERLINE, SHIFTLCD, SHIFTCURSOR, HOME
' CURSOR, DISPLAY
'micro : Mega8515
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
 
$regfile = "m8515.dat" ' Benutzter Mikrocontroller
$crystal = 4000000 ' Taktfrequenz
$baud = 19200 ' Baudrate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
 
 
$sim
'Entfernen Sie &&SIM wenn das Programm gebrannt werden soll !!
'$sim wird für eine schnellere Simulation verwendet.
 
 
'Anmerkung: Getestet mit PIN Mode mit 4-bit
 
'Config Lcdpin = Pin , Db4 = Portb.1 , Db5 = Portb.2 , Db6 = Portb.3 , Db7 = Portb.4 , E = Portb.5 , Rs = Portb.6
Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Portc.7 , Rs = Portc.6
'Settings für ein STK200 in PIN Mode
'Verbinden Sie DB4 bis DB7 des LCD mit dem LCD Anschluss des STK D4-D7
'Verbinden Sie E des LCD mit A15 (PORTC.7) und NICHT mit E des LCD Anschlusses
'Vervinden Sie RS, V0, GND und =5V des LCD mit dem STK LCD Anschluss
 
Rem Mit dem config lcdpin Befehl kann man die Stanfardwerte überschreiben
 
 
Dim A As Byte
Config Lcd = 16 * 2 'Konfigurieren des LC Displays.
 
 
'Andere Optionen sind 16 * 4 and 20 * 4, 20 * 2 , 16 * 1a
'Wenn nichts angegeben wird dann wird 16 * 2 angenommen
'16 * 1a wird benutzt für 16-Zeichen Displays mit über 2 Zeilen verteilten Adressen
 
'$LCD = address    Setzt das LC-Display in 8-Bit Mode
' Benutzen Sie das für uP mit externem RAM und/oder ROM
' weil die nicht die Portpins benutzen
 
Cls 'Löschen des LCD Displays
Lcd "Hello world." 'Anzeigen des Textes in der ersten Zeile
Wait 1
Lowerline 'Positionieren auf die unterste Zeile
Wait 1
Lcd "Shift this." 'Anzeigen in unterster Zeile
Wait 1
For A = 1 To 10
Shiftlcd Right 'Text nach rechts verschieben
Wait 1 'Etwas warten
Next
 
For A = 1 To 10
Shiftlcd Left 'Text nach links verschieben
Wait 1 'Einen Moment warten
Next
 
Locate 2 , 1 'Schreibmarke setzen
Lcd "*" 'Zeichen anzeigen
Wait 1 'warten
 
Shiftcursor Right 'Schreibmnarke verschieben
Lcd "@" 'Anzeigen
Wait 1 'warten
 
Home Upper 'Obere Zeile Position 1
Lcd "Replaced." 'Test anzeigen (alten überschreiben)
Wait 1 'wait a moment
 
Cursor Off Noblink 'Schreibmarke nicht anzeigen
Wait 1 'warten
Cursor On Blink 'Schreibmarke wieder anzeigen
Wait 1 'warten
Display Off 'Display ausschalten
Wait 1 'warten
Display On 'Display einschalten
'-----------------Neue Unterstützung von 4-Zeilen LC-Displays------
Thirdline
Lcd "Line 3"
Fourthline
Lcd "Line 4"
Home Third 'Gehe zu Home der dritten Zeile
Home Fourth
Home F 'Es reicht auch der erste Buchstabe
Locate 4 , 1 : Lcd "Line 4"
Wait 1
 
'Definition benutzerdefinierter Zeichen
'Die erste Ziffer ist die Zeichennummer (0-7)
'Die anderen Zahlen sind die Zeilenwerte
'Benutzen Sie das LCD Tool und Zeichen zu erstellen und diese Zahlen einzustellen
 
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 'Selektiere Daten RAM
Rem Es ist wichtig, dass ein CLS nach den DEFLCDCHAR Befehlen kommt weil das den LCD-Controller wieder in den Datenmode zurücksetzt.
Lcd Chr(0) ; Chr(1) 'Ausgabe von benutzterdefinierten Zeichen
 
'----------------- Benutzung einer internen Routine ------------
_temp1 = 1 'Wert in ACC
!rCall _write_lcd 'auf LCD schreiben
End

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language