@Hubert.G
ich bin gerade dabei mir Assembler beizubringen.
hab da ein Paar Zeilen Code geschriben, versuche erst eimal übersichtlichkeithalber mit 8-Bit-Modus.
hier poste ich's mal, falls jemand sich die Zeit nimmt wäre ich sehr dankbar.
@DolfoCode:;LCD-Ansteuerung im 8-Bit-Modus ;PORTC -- Datenbits DB0-DB7 ;Enable -- PD6 ;R/S -- PD7 ;R/W -- GND .INCLUDE "m16def.inc" .EQU XTAL=1000000 .DEF temp1=r16 .DEF temp2=r17 .DEF temp3=r18 .DEF temp4=r19 .DEF temp5=r20 .CSEG rjmp main .ORG $2A main: ldi temp1,LOW(RAMEND) out SPL,temp1 ldi temp1,HIGH(RAMEND) out SPH,temp1 ldi temp1,0x0F out DDRD,temp1 ldi temp1,0xFF out DDRB,temp1 out DDRC,temp1 rcall lcd_init rcall lcd_clear rcall lcd_home loop: ldi temp1,0x55 rcall lcd_data out PORTB,temp1 ;bloß Kontrolle rjmp loop lcd_enable: sbi PORTD,PD6 ;E setzten nop nop cbi PORTD,PD6 ;E zurück ret ;sendet ein Datenbyte an LCD lcd_data: sbi PORTD,PD7 ;R/S-Bit out PORTC,temp1 rcall lcd_enable rcall delay_5ms cbi PORTD,PD7 ;R/S-Bit ret ;sendet ein Befehl an LCD lcd_command: cbi PORTD,PD7 ;R/S-Bit out PORTC,temp1 rcall lcd_enable rcall delay_5ms ret ;initialisiert LCD lcd_init: push temp1 push temp3 ldi temp3,5 pow_upwait: rcall delay_5ms dec temp3 brne pow_upwait ldi temp1,0b00110000 out PORTC,temp1 cbi PORTD,PD7 rcall lcd_enable rcall delay_5ms ldi temp1, 0b00110000 ; 8bit-Modus einstellen out PORTC,temp1 rcall lcd_enable rcall delay_5ms ldi temp1,0b00110000 ; Functoin set rcall lcd_enable rcall delay_5ms ldi temp1,0b00010100 ; Cursor,Display,Shift rcall lcd_enable rcall delay_5ms ldi temp1,0b00001100 ; Display,on/off rcall lcd_enable rcall delay_5ms ldi temp1,0b00000110 ; Entry mode rcall lcd_enable rcall delay_5ms pop temp3 pop temp1 ret ;löscht LCD lcd_clear: push temp1 ldi temp1,0b00000001 ;Display löschen rcall lcd_command rcall delay_5ms pop temp1 ret ;cursor home lcd_home: push temp1 ldi temp1,0b00000010 ;cursor home rcall lcd_command rcall delay_5ms pop temp1 ret ;Warteschleifen delay_50us: push temp1 ldi temp1,20 ;Takt=1MHz delay_50us_: nop dec temp1 brne delay_50us ;verzweige bei=0 pop temp1 ret delay_5ms: push temp1 push temp2 ldi temp1,5 d_5ms_a: ldi temp2,100 ;100 dezimal d_5ms_i: nop ;interne Schleife=5Takte nop dec temp2 brne d_5ms_i ;gibt 500 Durchläufe=500us dec temp1 brne d_5ms_a nop pop temp2 pop temp1 ret .EXIT
hab nochmal alles gecheckt - Verdrahtungs- und Hardwarefehler kann man fast ausschliessen.
Chip-Select ("Enable") Signal schaltet auch mit acitve high (eigentlich wie alle anderen Pins)
du meinst wahrscheinlich R/S oder? weil R/W habe ich einfach auf GND gelegt.R/W Signal aktiviert (Befehle werden nur beim Pegelwechsel übernommen, müssen also schon vorher am Bus anliegen)?
und RS aktiviere ich nur wenn ich Daten senden will und keine Befehle.







Zitieren

Lesezeichen