Forum: Mikrocontroller und Digitale Elektronik Hilfe: LCD


von Baby (Gast)


Lesenswert?

Hallo zusammen

Ich habe eine 2x16 LCD und programmiere mit Assembler 4 Bit 
Interface(Atmega163 8MHz). Kann 1.Zeile ganz links und mitte anzeigen 
lassen. Aber 2.Zeile kriege ich nichts, obwohl ich für 4 bit Interface 
und 2 Zeilen Display schon definiere.

und für 2.Zeilebefehl ist

ldi temp, 0b11000000 ;2. Zeile 1pos.
rcall COMMAND_DISPLAY

LCD_INIT:
    ldi  temp,500      ; Wait at least 15msec after (200)
D1:          ; powerup before writing
  rcall  WAIT_2msec    ; to display
  dec  temp
  brne  D1
        ldi     temp, 00001100   ; System set 0b00010011
        out     PORTD,temp
        nop
        nop
    nop
    nop
    sbi    PORTD, EN
    nop
    nop
    nop
    nop
        cbi     PORTD,EN           ; EN low to clock in data
;
  rcall  WAIT_2msec    ; Wait 4 msec
  rcall  WAIT_2msec
;
        ldi     temp,0b00001100          ; System set
        out     PORTD,temp
        nop
    nop
    nop
    nop
    sbi    PORTD, EN
    nop
    nop
    nop
                nop
        cbi     PORTD,EN           ; EN low to clock in data

  rcall  WAIT_2msec    ; wait at least 100usec
  rcall  WAIT_2msec    ; wait at least 100usec

        ldi     temp,0b00001000         ;System set
        out     PORTD,temp
    nop
    nop
    nop
    nop
    sbi PORTD, EN
        nop
    nop
    nop
    nop
        cbi     PORTD,EN           ; EN low to clock in data
;
        rcall   WAIT_2msec               ; (2 msec)

    ldi temp,0b00001000   ;System set 4 bit Display
    out PORTD, temp
    nop
    nop
    nop
    nop
    sbi PORTD, EN
    nop
    nop
    nop
    nop
    cbi  PORTD, EN
    rcall WAIT_2msec
        ldi     temp,0b00101000         ; Function set
                                 ; 4 bit mode, 2 lines 5X7 pixels

         rcall   COMMAND_DISPLAY    ;write to display

        ldi     temp,0b00001000         ;Display off, cursor off
                                        ; blink off
        rcall   COMMAND_DISPLAY
;
        ldi     temp,0b00000110         ; Entry mode set
                                      ; Increment RAM, dont shift 
display
        rcall   COMMAND_DISPLAY
;
        ldi     temp,0b00001100    ; Display on, cursor/blink off
        rcall   COMMAND_DISPLAY
  ret

Was ich hier falsch gemacht habe.
Vielen Dank für Eure Hilfe
Baby

von Jornbyte (Gast)


Lesenswert?

In der Codesammlung gibt es ->
LCD 4Bit modus und BF flag mit Menue Text ausgabe AVR Assembler <- Schau 
dir das mal an.

von Baby (Gast)


Lesenswert?

Hallo Jornbyte

Vielen Dank für Deine Hilfe. Ich habe den Fehler gefunden, es ist bei 
COMMAND_DISPLAY. Wenn man solche Anschlüsse hat:

4bit-Interface
DB4-DB7:        PD0-PD3(AVR)
RS:             PD4
EN:             PD5
Dann,es muss so sein

COMMAND_DISPLAY:
        mov     temp_1,temp     ; Copy data to temp_1
        andi    temp,0b11110000 ; mask off lower 4 bits
  swap  temp    ; To correct for board error
        cbr  temp, 1<<RS     ; RS auf low (Command)
        out     PORTD,temp        ; write upper 4 bits to display  nop
  sbi     PORTD,EN         ; EN bit high
        nop                      ; wait 1 usec total command
        nop
  nop
  nop                              ; Stabilize line
        cbi     PORTD,EN         ; EN low to clock in data
        swap    temp_1    ; get lower 4 bits
        andi    temp_1,0b11110000       ; mask off lower 4 bits
  swap  temp_1    ; To correct for board error
        cbr  temp, 1<<RS     ;RS auf low (Command)
        out     PORTD,temp_1    ;write lower 4 bits to LCD
  sbi     PORTD,EN       ; EN high
        nop                             ;
        nop
  nop
  nop                                     ;
        cbi     PORTD,EN         ; EN low to clock in data
        ldi     Delay,200       ; Wait about 50 usec
D4:
      dec     Delay
        brne    D4
        ret         ; return

Was falsch war, dass ich anstatt "cbr  temp, 1<<RS" schreiben muss, habe 
ich nur "cbr temp, RS" geschrieben.

Gruss Baby

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.