Forum: Mikrocontroller und Digitale Elektronik lcd-routines.asm fehlerhaft!


von Wire (Gast)


Lesenswert?

Ich habe quelle reinkopiert. was sehe ich? 24x illegal argument type or
count
8x Undefinied variable referenced

ich habe atmega8.

von Peter D. (peda)


Lesenswert?

Du weißt schon, daß keiner in Deinen Kopf sehen kann ?

Wenn du hier also einen Fehler monieren willst, dann mindestens mit
Quelltextzeile und Fehlermeldung.

So ein Beitrag wie Deiner ist jedenfalls völlig überflüssig.


Peter

von Wire (Gast)


Lesenswert?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;                 LCD-Routinen                ;;
;;                 ============                ;;
;;              (c)andreas-s@web.de            ;;
;;                                             ;;
;; 4bit-Interface                              ;;
;; DB4-DB7:       PD0-PD3                      ;;
;; RS:            PD4                          ;;
;; E:             PD5                          ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



 ;sendet ein Datenbyte an das LCD
lcd_data:
           mov temp2, temp1             ;"Sicherungskopie" für
                                        ;die Übertragung des 2.Nibbles
           swap temp1                   ;Vertauschen
           andi temp1, 0b00001111       ;oberes Nibble auf Null setzen
           sbr temp1, 1<<4              ;entspricht 0b00010000
           out PORTD, temp1             ;ausgeben
           rcall lcd_enable             ;Enable-Routine aufrufen
                                        ;2. Nibble, kein swap da es
schon
                                        ;an der richtigen stelle ist
           andi temp2, 0b00001111       ;obere Hälfte auf Null setzen
           sbr temp2, 1<<4              ;entspricht 0b00010000
           out PORTD, temp2             ;ausgeben
           rcall lcd_enable             ;Enable-Routine aufrufen
           rcall delay50us              ;Delay-Routine aufrufen
           ret                          ;zurück zum Hauptprogramm

 ;sendet einen Befehl an das LCD
lcd_command:                            ;wie lcd_data, nur ohne RS zu
setzen
           mov temp2, temp1
           swap temp1
           andi temp1, 0b00001111
           out PORTD, temp1
           rcall lcd_enable
           andi temp2, 0b00001111
           out PORTD, temp2
           rcall lcd_enable
           rcall delay50us
           ret

 ;erzeugt den Enable-Puls
lcd_enable:
           sbi PORTD, 5                 ;Enable high
           nop                          ;3 Taktzyklen warten
           nop
           nop
           cbi PORTD, 5                 ;Enable wieder low
           ret                          ;Und wieder zurück


 ;Pause nach jeder Übertragung
delay50us:                              ;50us Pause
           ldi  temp1, $42
delay50us_:dec  temp1
           brne delay50us_
           ret                          ;wieder zurück

 ;Längere Pause für manche Befehle
delay5ms:                               ;5ms Pause
           ldi  temp1, $21
WGLOOP0:   ldi  temp2, $C9
WGLOOP1:   dec  temp2
           brne WGLOOP1
           dec  temp1
           brne WGLOOP0
           ret                          ;wieder zurück

 ;Initialisierung: muss ganz am Anfang des Programms aufgerufen werden
lcd_init:
           ldi  temp3,50
powerupwait:
           rcall  delay5ms
           dec  temp3
           brne  powerupwait
           ldi temp1, 0b00000011        ;muss 3mal hintereinander
gesendet
           out PORTD, temp1             ;werden zur Initialisierung
           rcall lcd_enable             ;1
           rcall delay5ms
           rcall lcd_enable             ;2
           rcall delay5ms
           rcall lcd_enable             ;und 3!
           rcall delay5ms
           ldi temp1, 0b00000010        ;4bit-Modus einstellen
           out PORTD, temp1
           rcall lcd_enable
           rcall delay5ms
           ldi temp1, 0b00101000        ;noch was einstellen...
           rcall lcd_command
           ldi temp1, 0b00001100        ;...nochwas...
           rcall lcd_command
           ldi temp1, 0b00000100        ;endlich fertig
           rcall lcd_command
           ret

 ;Sendet den Befehl zur Löschung des Displays
lcd_clear:
           ldi temp1, 0b00000001   ;Display löschen
           rcall lcd_command
           rcall delay5ms
           ret

von Tobi (Gast)


Lesenswert?

@wire:
meine vermutung: du hast vergessen irgendwo die inc file für deinen uC
einzubinden

von Peter D. (peda)


Lesenswert?

Und wo sind die Fehlermeldungen ?


Was sofort auffällt, es fehlen die Definitionen für temp2 usw. und
mindestens ein RJMP von 0x0000 zum Programmstart.

Und bei langen Texten immer die Option "Dateianhang" nutzen !


Peter

von raoul (Gast)


Lesenswert?

bei mir funktioniert diese routine einwandfrei! also nix mit fehlern
oder so, außer du hast etwas verädert...

mfg

von Wire (Gast)


Lesenswert?

C:\Programme\Atmel\AVR
Tools\AvrStudio\lcd_routines.asm(16):error:Illegal argument type or
count
C:\Programme\Atmel\AVR
Tools\AvrStudio\lcd_routines.asm(18):error:Illegal argument type or
count
C:\Programme\Atmel\AVR
Tools\AvrStudio\lcd_routines.asm(19):error:Illegal argument type or
count
C:\Programme\Atmel\AVR
Tools\AvrStudio\lcd_routines.asm(20):error:Illegal argument type or
count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(21):error:Undefinied variable referenced
C:\Programme\Atmel\AVR
Tools\AvrStudio\lcd_routines.asm(25):error:Illegal argument type or
count
C:\Programme\Atmel\AVR
Tools\AvrStudio\lcd_routines.asm(26):error:Illegal argument type or
count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(27):error:Undefinied variable referenced
C:\Programme\Atmel\AVR
Tools\AvrStudio\lcd_routines.asm(34):error:Illegal argument type or
count
C:\Programme\Atmel\AVR
Tools\AvrStudio\lcd_routines.asm(35):error:Illegal argument type or
count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(36):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(39):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(40):error:Undefinied variable referenced
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(47):error:Undefinied variable referenced
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(51):error:Undefinied variable referenced
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(56):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(57):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(63):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(64):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(65):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(67):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(73):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(76):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(78):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(79):error:Undefinied variable referenced
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(86):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(87):error:Undefinied variable referenced
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(90):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(92):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(94):error:Illegal argument type or count
C:\Programme\Atmel\AVR Tools\AvrStudio\lcd_routines.asm(
(100):error:Illegal argument type or count

von dave (Gast)


Lesenswert?

Du hast also ein Projekt, bei dem du oben alle
.DEF temp1 = r16
.DEF temp2 = r17
.DEF temp3 = r18

Und außerdem hast du oben das angehängt:
.INCLUDE "m8def.inc" oder ähnliches?

[Ironie]Aber du hast da sicher nix vergessen[/Ironie]

dave

von Tobi (Gast)


Lesenswert?

und du weisst auch, dass das was du oben gepostet hast kein ganzen
programm ist, sondern nur eine include datei...

von ...HanneS... (Gast)


Lesenswert?

Copy & Paste alleine macht noch kein(en) Programm(ierer), man sollte
auch versuchen, den Code zu verstehen.

Und bevor man solch recht komplexen Dinge wie LCD einbindet, sollte man
erstmal das "kleine Einmaleins" lernen (Registerdefinitionen,
grundsätzlicher Programmaufbau, Reset- & Int-Vektoren usw.).

Rom wurde auch nicht an einem Tag erbaut.

...

von Peter D. (peda)


Lesenswert?

Ich sehe es genau so wie HanneS,

der Fehler liegt bestimmt nicht im lcd_routines.asm sondern eher in den
ungenügenden Kenntnissen über den Aufbau eines Programms.

Ereigniskarte:
Gehe zurück zu Start und versuche erstmal ne LED blinken zu lassen.
Ziehe nicht 2000 € ein.


Peter

von ...HanneS... (Gast)


Lesenswert?

Übrigens: Ein Doppelklick auf den jeweiligen Eintrag in der Fehlerliste
zeigt dir den Fehler im Quelltext an.

Das ist sehr hilfreich, diese Fehler treten nämlich (zumindest bei mir)
öfters mal auf wenn ich z.B. wieder mal einen "Variablennamen"
(Register-Alias) oder ein Label falsch geschrieben habe...

@Peter: Danke, dass du meine "Frechheit" unterstützt... ;-)

...

von MichaB (Gast)


Lesenswert?

Wire,

Du hast im AVR Studio die beiden .asm aus dem tut hinzugefügt und
drückst dann F7 für Compile... Dann bekommst Du die Fehlermeldungen.

Beim Hinzufügen hast Du erst die LCD-Routines.asm und dann die
LCD-Test.asm hinzugefügt, damit hast Du als "Entry-File" die LCD
Routines drin, das ist aber nicht das Entry File, sondern nur die
Include Datei.

Lösung:
Geh mal mit der rechten Maustaste auf die LCD-Test und klicke auf Set
as Entry File... und schon kannst Du kompilieren !!

Micha

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
Noch kein Account? Hier anmelden.