Hi, ich steuere mein LCD über einen 8Bit Bus an (ATMEGA32L). Funktioniert nun alles gut, allerdings habe ich das Problem mit dem Wechsel auf die höherwertigeren 8 Bit. Da es nur ein 1 Zeilen Display ist, sagt mir das Datenblatt folgende DD RAM Tabelle. Characters: 1 2 3 4 5 6 7 8 9 10 11 12 etc.. 00H 01H 02H 03H 04H 05H 06H 07H 40H 41H etc... So wie ich das verstanden habe muss ich also bei einem Wechsel auf Character 9-16 folgendes Kommando an das LCD senden. LCDWriteByte(0x80+0x40); Leiders springt er da nicht hin. Ein LCDWriteByte(0x80+0x03); funktioniert hingegen schon. Was mache ich falsch ? Grüsse Matthias
Wenn ich vorher ein Cursor Home Befehl sende bevor ich den Sprung mache, bekomme ich bei Position 9 plötzlich diese Zeichen LCD Ausgabe: "Das ist |||" anstatt "Das ist ein Test" Vielleicht hilft das ? Grüsse Matthias
@ Matthias (Gast) >So wie ich das verstanden habe muss ich also bei einem Wechsel auf >Character 9-16 folgendes Kommando an das LCD senden. >LCDWriteByte(0x80+0x40); Ist LCDWriteByte wirklich dazu da KOMMANDOS zu senden? Oder doch eher Daten. Der entscheidende Unterschied ist das RS Signal! MFG Falk
Vollkommen sicher RS wird für Kommandos extra auf 0 gesetzt
Da ich das das erste mal mache habe ich jetzt den "dummen" Fehler gefunden. Ich habe bei Initialisieren ein "Ein Zeilen Display" angegeben, habe ja auch ein 16x1 Display. Allerdings wird das ganze in 8x2 "konvertiert" und somit muss in in den 2 Zeilen Mode Wechseln beim Initialisieren. So nun werd ich es nie wieder falsch machen ;-) Es geht nun wunderbar Danke und Grüsse
Hallo, wo muss ich bei einem 16x1 LCD Display den Befehl movlw H'40' zum Zeilenwechsel einbinden? Hier das Programm: ;*********************************************************************** ;Ansteuerung eines LCD Displays ;PIC 16F628 ;Takt 4MHz ; ;06.08.09 ;*********************************************************************** ;Pinbelegung des PIC**************************************************** ;*********************************************************************** ; PortB,0 -> Enable ; PortB,1 -> not connected ; PortB,2 -> RS (Register Select) ; PortB,3 -> RW (Read / Write) ; PortB,4 -> D4 (Datenbus 4 bittig) ; PortB,5 -> D5 (Datenbus 4 bittig) ; PortB,6 -> D6 (Datenbus 4 bittig) ; PortB,7 -> D7 (Datenbus 4 bittig) ; ; RS = 1 -> Daten des Datenbusses werden als Zeichen in den Textpuffer übertragen ; RS = 0 -> Daten des Datenbusses werden als Befehl in der Steuerregister geschrieben ; ; RW = 1 -> Lesefunktion ; RW = 0 -> Schreibfunktion ;*********************************************************************** ;Varablen vereinbaren*************************************************** ;*********************************************************************** loops equ 0x20 ; timer für wait loops2 equ 0x21 ; timer für wait loops3 equ 0x22 loops4 equ 0x23 loops5 equ 0x24 LcdStatus equ 0x25 ; LcdDaten equ 0x26 ; ;LcdE equ PortB,0 ; enable Lcd ;LcdRw equ PORTB,3 ; read/write Lcd ;LcdRs equ PORTB,2 ; Daten Lcd (nicht control) ;*********************************************************************** ;Programm starten******************************************************* ;*********************************************************************** org 0x00 goto Init ;*********************************************************************** ;Initialisierung des PIC************************************************ ;*********************************************************************** Init bsf status,rp0 ; select Bank1 movlw B'00000010' ; Pull up resistors activ movwf option_reg movlw B'11111111' ; PortA all input movwf trisa movlw B'00000000' ; PortB all output movwf trisb bcf status,rp0 ; select Bank0 movlw B'00000000' ; Interrupt disable movwf Intcon ;*********************************************************************** ;Hauptprogramm********************************************************** ;*********************************************************************** Main call InitLcd Out movlw 'G' movwf LcdDaten call OutLcdDaten movlw 'u' movwf LcdDaten call OutLcdDaten movlw 't' movwf LcdDaten call OutLcdDaten movlw 'e' movwf LcdDaten call OutLcdDaten movlw 'n' movwf LcdDaten call OutLcdDaten movlw ' ' movwf LcdDaten call OutLcdDaten movlw 'T' movwf LcdDaten call OutLcdDaten movlw 'a' movwf LcdDaten call OutLcdDaten ; 8 Zeichen fertig ; ACHTUNG ; Einfuegen eines Zeilenwechsels beim 2x8-Display ; die folgenden 2 Zeilen nur bei einem 1-Zeiligen Display 1x16 (intern 2x8 organisiert) movlw 'g' movwf LcdDaten call OutLcdDaten ;*********************************************************************** ;LCD initialisieren***************************************************** ;*********************************************************************** InitLcd movlw D'150' ; Delay after Vdd rises to 4,5V movwf loops call Wait bcf PortB,0 ; defined status for enable bit bcf PortB,2 ; RS = 0 -> instruction signal bcf PortB,3 ; RW = 0 -> write mode movlw B'00110000' ; InitLcd step 1: 8 bit interface call Transmit ; transfer 8 bit instruction signal movlw B'00110000' ; InitLcd step 2: 8 bit interface call Transmit ; transfer 8 bit instruction signal movlw B'00110000' ; InitLcd step 3: 8 bit interface call Transmit ; transfer 8 bit instruction signal movlw B'00100000' ; InitLcd step 4: 4 bit interface call Transmit ; transfer 8 bit instruction signal call LcdBusy ; Lcd busy? If Lcd busy, busy flag is high (PortB,7) movlw B'00000001' ; clear und cusor home call OutLcdControl movlw B'00101000' ; function set, 4-bit 2-zeilig, 5x7 call OutLcdControl movlw B'00001000' ; display off call OutLcdControl movlw B'00000110' ; entry mode, increment, disable display-shift call OutLcdControl ;movlw B'00000011' ; cursor home, cursor home ;call OutLcdControl movlw B'00001100' ; display on, cursor off, cursor flash off call OutLcdControl ;*********************************************************************** ;Transfer 8 bit intruction signal*************************************** ;*********************************************************************** Transmit movwf PortB ; Data to Databus bsf PortB,0 ; enable Chip signal nop ; wait bcf PortB,0 ; disable Chip signal movlw D'50' ; Delay of 50ms movwf loops call Wait return ;*********************************************************************** ;LCD busy at the moment?************************************************ ;*********************************************************************** LcdBusy bsf STATUS, RP0 ; make Port B4..7 input movlw B'11110000' iorwf TRISB, f bcf STATUS, RP0 BusyLoop bcf PortB,2 bsf PortB,3 ; Lesen bsf PortB,0 nop movf PortB, w movwf LcdStatus bcf PortB,0 nop bsf PortB,0 ; Enable nop bcf PortB,0 btfsc LcdStatus, 7 ; teste bit 7 goto BusyLoop bcf PortB,3 bsf STATUS, RP0 ; make Port B4..7 output movlw B'00001111' andwf TRISB, f bcf STATUS, RP0 return ;******************************************************************** ;aus W ein Byte mit Steuerdaten zum Display übertragen*************** ;******************************************************************** OutLcdControl movwf PortB call LcdBusy movf LcdDaten, w andlw H'F0' movwf PortB ; Hi-teil Daten schreiben bsf PortB,0 nop bcf PortB,0 ; Disable LcdBus swapf LcdDaten, w andlw H'F0' movwf PortB ; Lo-teil Daten schreiben bsf PortB,0 nop bcf PortB,0 ; Disable LcdBus return ;******************************************************************* ;aus W ein Datenbyte zum Display übertragen************************* ;******************************************************************* OutLcdDaten movwf LcdDaten call LcdBusy movf LcdDaten, w andlw H'F0' movwf PortB ; Hi-teil Daten schreiben bsf PortB,2 ; Daten bsf PortB,0 ; Enable LcdBus nop bcf PortB,0 ; Disable LcdBus swapf LcdDaten, w andlw H'F0' movwf PortB ; Lo-teil Daten schreiben bsf PortB,2 ; Daten bsf PortB,0 nop bcf PortB,0 ; Disable LcdBus bcf PortB,2 ; return ;******************************************************************* ;Subroutines******************************************************** ;******************************************************************* ;Zeitverzögerung um loops * 1 ms ; 4 MHz externer Takt bedeutet 1 MHz interner Takt ; also dauert 1 ms genau 1000 Befehle ; 100 Schleifen a 10 Befehle sind 1000 Befehle = 1 ms WAIT top movlw D'100' ; timing adjustment variable (1ms) movwf loops2 top2 nop ; sit and wait nop nop nop nop nop nop decfsz loops2, F ; inner loops complete? goto top2 ; no, go again decfsz loops, F ; outer loops complete? goto top ; no, go again retlw 0 ; yes, return from WAIT ;Zeitverzögerung ;100 Schleifen a 10 Befehle sind 1000 Befehle = 1 ms ;1 ms x 100 Schleifen = 100 ms ;100ms x 10 = 2000 ms = 1 sek Delay ;******* top3 movlw D'10' movwf loops3 ;******* top4 movlw D'100' movwf loops4 ;******* top5 movlw D'100' movwf loops5 ;******* top6 nop nop nop nop ; die Schleife top6 wird mit 10 Befehlen 100x durchlaufen -> 1 ms nop nop nop decfsz loops5,f goto top6 ;******* decfsz loops4,f ; wurde die Schleife top6 100x durchlaufen, gehe zu top5 -> 100 x 1 ms goto top5 ;******* decfsz loops3,f ; wurde die schleife 10 x für 100 ms durchlaufen? goto top4 ; nein retlw 0 ; ja ;********************************************************************
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.