Hallo,
ich habe versucht seit paar Tage, ein LCD mit Pic16F88 zu steuern, die
Hintergrund leuchtet, aber die Buchstabern werden nicht dargestellt.
ich hoffe dass jemand mir helfen kann, ich bedanke mich,
die Verbindung zwischen Pic und LCD wie folgt:
RA0-------D4
RA1-------D5
RA2-------D6
RA3-------D7
RB0-------RS
RB1-------R/W
RB2-------E
Assembler Code
#include <P16F88.inc>
; Variablen festlegen
w_copy Equ 0x21
s_copy Equ 0x22
LcdDaten Equ 0x23
LcdStatus Equ 0x24
Wait1 Equ 0x25
Wait2 Equ 0x26
Wait3 Equ 0x28
Wait4 Equ 0x29
x Equ 0x27
;Konstanten
LcdE equ 2 ; enable Lcd
LcdRw equ 1 ; read Lcd
LcdRs equ 0 ; Daten Lcd (nicht control)
org 0x0000
ERRORLEVEL -302
;
__CONFIG _CONFIG1, _PWRTE_ON & _WDT_OFF & _CCP1_RB0
;
goto MainInit
MainInit
bsf STATUS, RP0
clrf OSCTUNE
movlw b'0000110'
movwf OSCCON
movlw 0x00
movwf ANSEL
clrf TRISA
clrf TRISB
bcf STATUS,RP0
call InitLCD ; Display initialisieren
movlw 'H'
movwf LcdDaten
call OutLcdDaten
movlw 'a'
movwf LcdDaten
call OutLcdDaten
movlw 'l'
movwf LcdDaten
call OutLcdDaten
movlw 'l'
movwf LcdDaten
call OutLcdDaten
movlw 'o'
movwf LcdDaten
call OutLcdDaten
sleep
Main
goto Main
InitLCD
call Warten250
movlw B'00000011' ; 1
movwf PORTA
bsf PORTB, LcdE
nop
bcf PORTB, LcdE
call Warten50
movlw B'00000011' ; 2
call Control8Bit
movlw B'00000011' ; 3
call Control8Bit
movlw B'00000010' ; 4
call Control8Bit
movlw B'00000001' ; löschen und cusor home
call OutLcdControl
movlw B'00101000' ; 5 function set, 4-bit 2-zeilig, 5x7
call OutLcdControl
movlw B'00001000' ; 6 display off
call OutLcdControl
movlw B'00000110' ; 7 entry mode, increment, disable display-shift
call OutLcdControl
movlw B'00000011' ; 8 cursor home, cursor home
call OutLcdControl
movlw B'00001111' ; 9 display on
call OutLcdControl
return
; ein Steuerbyte 8-bittig übertragen
Control8Bit
movwf PORTA
bsf PORTB, LcdE
nop
bcf PORTB, LcdE
call Warten10
return
LcdBusy
; bsf PORTA, 1 ; Test LED 1 on
bsf STATUS, RP0 ; make Port B4..7 input
movlw B'11110000'
iorwf TRISB, f
bcf STATUS, RP0
return
; ein Byte mit Steuerdaten von LcdDaten zum Display übertragen
OutLcdControl
movwf LcdDaten
call LcdBusy
movf LcdDaten, w
andlw H'F0'
movwf x
swapf x,1
movfw x
movwf PORTA ; Hi-teil Daten schreiben
bsf PORTB, LcdE
nop
bcf PORTB, LcdE ; Disable LcdBus
movfw LcdDaten
andlw H'0F'
movwf PORTA ; Lo-teil Daten schreiben
bsf PORTB, LcdE
nop
bcf PORTB, LcdE ; Disable LcdBus
return
; ein Datenbyte von LCDDaten zum Display übertragen
OutLcdDaten
movwf LcdDaten
call LcdBusy
movf LcdDaten, w
andlw H'F0'
movwf x
swapf x,1
movfw x
movwf PORTA ; Hi-teil Daten schreiben
bsf PORTB, LcdRs ; Daten
bsf PORTB, LcdE ; Enable LcdBus
nop
bcf PORTB, LcdE ; Disable LcdBus
movfw LcdDaten
andlw H'0F'
movwf PORTA ; Lo-teil Daten schreiben
bsf PORTB, LcdRs ; Daten
bsf PORTB, LcdE
nop
bcf PORTB, LcdE ; Disable LcdBus
bcf PORTB, LcdRs ;
return
Warten10
movlw .10
movwf Wait4
decfsz Wait4, F
call Warten
retlw .0
Warten50
movlw .50
movwf Wait3
decfsz Wait3, F
call Warten
retlw .0
Warten250
movlw .250
movwf Wait2
decfsz Wait2, F
call Warten
retlw .0
Warten
movlw .110 ; Zeitkonstante für 1ms
movwf Wait1
loop
nop
nop
nop
nop
nop
nop
decfsz Wait1, F ; 1 ms vorbei?
goto loop ; nein, noch nicht
retlw .0
end
passt der kontrast denn? wenn du das lcd anschaltest, solltest du in der 1. zeile viele schwarze kästchen sehen. welcher controller ist auf dem lcd? Klaus.
>Kontrast passt, die kästchen siehe ich, der Controller ist HD44780
Wenn die Kästchen nicht weggehen stimmt deine Init nicht
oder das Timing bei z.B. E ist falsch.
tja, dann gibt genau für den controller und das lcd ja haufenweise beispiele im netz. tut das nicht, liegt es an deiner hardware, den fuses oder sonstwas...der teufel steckt im detail und meistens nicht im beispiel-code :) wieso eigentlich nicht C? oder bascom (würg)? Klaus.
>wieso eigentlich nicht C? oder bascom (würg)? Das ist vielleicht ein PIC, -da wird das mit Bascom nichts werden. Aber frag ruhig... http://www.hier-ist-dein-schild.de/ SCNR Paul
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.