Forum: Mikrocontroller und Digitale Elektronik LCD Testroutine gesucht...


von BA (Gast)


Lesenswert?

für 16x2 oder 16x4 LCD mit HD44780 Kontroller...
am besten für STK200 angepasst...

von Holger Barske (Gast)


Lesenswert?

Schon wieder ich...

http://www.avr-forum.com/programs/Bas_lcd.asm

Gutes Gelingen!

Holger

von BA (Gast)


Lesenswert?

das hab ich geschrieben und es lüppt einfach net...
mitlerweile glaube ich das dieses scheiss LCD im arsch ist..
schaut das mal durch was ich da für ein blödsinn verzapft habe..
thx..:-))..und danke schonmal


;*********************************************************
;    Anschlussplan Display to AVR
;---------------------------------------------------------
;     Pin Belegung Display  : Pin Belegung AT90S8515
;---------------------------------------------------------
; 1.  GND                       :  ----------
; 2.  +5V      :  ----------
; 3.  Vo Contrast    :  über 10k auf +5V
; 4.  RS Daten oder Code Input  : 21.  PC0
; 5.  R/W       : 22.  PC1
; 6.  Enable      : 23.  PC2
; 7.  DB0      : 39.   PA0
; 8.  DB1      : 38.  PA1
; 9.  DB2      : 37.  PA2
; 10. DB3      : 36.  PA3
; 11. DB4      : 35.  PA4
; 12. DB5      : 34.  PA5
; 13. DB6      : 33.  PA6
; 14. DB7      : 32.  PA7
; 15. Anode  LED    :  ----------
; 16. Katode LED    :  ----------
;*********************************************************

.nolist
.device  AT90S8515              ; Festlegung des Prozessors
.include "8515def.inc              ; Adressdefinierung einfügen für 
AT90S8515
.list

;**** Definierung der Steuerleitungen ****

.equ  E  =  PC2            ; Enable Leitung
.equ  RW  =  PC1            ; Read / Write Leitung
.equ  RS  =  PC0            ; Befehlsleitung
.equ  Busy  =  PA7            ; Busy Leitung

; **** Definierung der Befehle ****

.equ  lcdon  =  0b00001111          ; LCD einschalten
.equ  lcdmode  =  0b00111000          ; LCD Mode einstelle 8 Bit, 2 
Zeilen
.equ  lcdclear=  0b00000001          ; LCD löschen
.equ  lcdentry=  0b00000110          ; bei eingabe eines Zeichen den 
Cursor um 1 erhöhen


; **** Definierung der Arbeitsregister *****

.def  temp1  =  r16            ; Arbeitsregister 1
.def  temp2  =  r17            ; Arbeitsregister 2
.def  tim1  =  r18            ; Timeregister
.def  tim2  =  r19

; **** Hauptprogramm ****

main:

  ldi  temp1,High(RamEnd)          ; >
  out  sph,temp1            ;   > Stack Initialisieren
  ldi  temp1,Low(RamEnd)          ; >
  out  spl,temp1

  ldi  temp1,0b11111111          ; Port A als komplett als Ausgänge
  out  ddra,temp1            ; setzten
  out  ddrc,temp1            ; ebenfalls Port C



; **** Initialisierung des LCD Displays ****

initlcd:

  rcall   wait15ms            ; 15ms auf Display warten

  ldi  temp1,lcdmode
  rcall  sendebefehl
  rcall  wait5ms
  ldi  temp1,lcdon
  rcall  sendebefehl
  rcall  wait5ms
  ldi  temp1,lcdentry
  rcall  sendebefehl
  rcall  wait5ms
  ldi  temp1,0b01001000
  rcall  sendedaten


;  ldi  temp1,lcdmode
;  rcall  sendebefehl
;  rcall  wait150us
;  ldi  temp1,lcdmode
;  rcall  sendebefehl
;  rcall  wait150us
;  ldi  temp1,lcdon
;  rcall  sendebefehl
;  rcall  wait150us
;  ldi  temp1,lcdclear
;  rcall  sendebefehl

loop:
  rjmp loop


sendebefehl:

  cbi  portc,RS
  rcall  ausgabe
  ret

sendedaten:

  sbi  portc,RS
  rcall  ausgabe
  ret

ausgabe:

  out  portc,temp1
  sbi  portc,E
  nop
  nop
  nop
  cbi  portc,E
  ret


; **** Zeitschleifen ****

wait50us:

  ldi  tim1,65              ; 50us warten bei 4MHz Tacktfrequenz
  wait51:                ; 50us / 750ns = 65
  dec  tim1              ; 250ns für DEC Befehl und 500ns für BRNE
  brne   wait51              ; Befehl = 750ns
  ret                ; 750ns * 65 Durchläufe = 50us

wait150us:

  rcall wait50us
  rcall wait50us
  rcall wait50us
  ret

wait5ms:

  ldi  tim2,100
  wait5:
  rcall  wait50us
  dec  tim2
  brne  wait5
  ret

wait15ms:

  rcall  wait5ms
  rcall  wait5ms
  rcall  wait5ms
  ret

von BA (Gast)


Lesenswert?

ich versuchs mal mit nem anhang...

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.