Hallo Leute,
kann mal jemand da rüberschauen? Mein LCD wird nur zugemüllt mit Buchstaben!
Gruß Alex
Code:.include "m8535def.inc" ;Definitionsdatei einbinden m8535def.inc ;-------------------------------------------------------------------------- ldi r16, 0x2 ;Stapelzeiger eingerichtet out sph, r16 ldi r16, 0x5F out spl, r16 ;-------------------------------------------------------------------------- ;-----Deklarationen-------------------------------------------------------- ; EN = PORTA, 7 ; RW = PORTA, 6 ; RS = PORTA, 5 .SET LCD = PORTC ;-------------------------------------------------------------------------- ser r16 ; setzte Register auf 0xFF out DDRC, r16 ; PortC&D als Ausgang konfiguriert out DDRA, r16 call busy_flag ldi r17, 0b00111000 ; 3x 8Bit initialisieren out LCD, r17 call send_lcd call busy_flag call send_lcd call busy_flag call send_lcd ldi r17, 0b00001000 ; Display aus out LCD, r17 call send_lcd call busy_flag ldi r17, 0b00000001 ; Display löschen out LCD, r17 call send_lcd call busy_flag ldi r17, 0b00000110 ; Entry Set out LCD, r17 call send_lcd call busy_flag ldi r17, 0b00001100 ; Display an out LCD, r17 call send_lcd call print ende: jmp ende ;------------------------------------------------------------- send_lcd: sbi PORTA, 7 ; L/H Flanke Enable nop nop nop nop cbi PORTA, 7 ; H/L Flanke Enable ret ;------------------------------------------------------------- busy_flag: sbi PORTA, 6 ; R/W & RS konfigurieren cbi PORTA, 5 ; fürs busy sbi PORTA, 7 ; Flanke Enable nop nop nop nop testen: sbic PORTC, 7 ; Busy lesen rjmp testen ; polling bis frei cbi PORTA, 7 ; Enable auf Low cbi PORTA, 6 ; RS & R/W löschen für cbi PORTA, 5 ; weitere Konfiguration ret ; raus aus warten ;------------------------------------------------------------- print: ldi ZH, high(2*Text) ; Pointer adressieren ldi ZL, low(2*Text) sbi PORTA, 5 ; RS und R/W konfigurieren cbi PORTA, 6 ; zum schreiben rw: lpm r0,z+ ; hole wert adressiert durch z in r0 und inc z out PORTC, r0 ; Ausgabe an Interface LCD mov r16, r0 ; Kopieren für Vergleich in r16 cpi r16,0 ; Vergleich ob "0" brne ok ; Keine "0"?, dann "ok" ret ; doch "0", dann surüg ;-) ok: call send_lcd ; is klar! rjmp rw ; weiter Zeichenausgabe bis endlich "0" Text: .DB "initialized",0







Zitieren

Lesezeichen