;Festlegung ;RB4 --> LCD Bit4 ;RB5 --> LCD Bit5 ;RB6 --> LCD Bit6 ;RB7 --> LCD Bit7 ;RC6 --> LCD E fallende Flanke notwendig ;RC7 --> LCD RS High-->Daten Low-->Befehle #define E PORTC,6 #define RS PORTC,7 ;LCD Iniziallisierung lcd_init movlw d'50' movwf zaehler2 lcd_init_1 call wait2ms decfsz zaehler2,1 goto lcd_init_1 movlw b'00100000' ;0 ,0 ,1 ,0=initialisierung 4bit movwf PORTB bcf RS bsf E nop nop nop bcf E call wait2ms movlw b'00100100' ;0 ,0 ,1 ,0=initialisierung 4bit, 0, 1= Umschalten auf "extendet Funktion set", da 4zeiliges Display call lcd_befehle ;und diese einstellung erfolgt im "extendet Funktion set", den im normal modus call wait2ms ;ist nur 2line display einstellbar, movlw b'00001001' ;0, 0, 0, 0, 1=extendet Funktion set, 0=5dot, 0=normal curser, 1=4line display call lcd_befehle movlw b'00100000' ;initialisierung 4bit - Umschalten auf normal Funktion call lcd_befehle movlw b'00001100' ;0, 0, 0, 0, 1, 1=Display ein, 0=Cursor aus, 0=Blinken aus call lcd_befehle movlw b'00000110' ;0, 0, 0, 0, 0, 1, 1=Cursor increase, 0=Display not shifted call lcd_befehle movlw b'00000010' ;cursor home call lcd_befehle call wait2ms movlw b'00000001' ;Display löschen call lcd_befehle call wait2ms return ;LCD-Anwendungen ;Enable - Funktion EN bsf E nop nop nop bcf E call wait50ss return ;LCD - Befehle - Funktion lcd_befehle movwf speicher movf speicher,w movwf PORTB bcf RS nop nop call EN swapf speicher,w movwf PORTB bcf RS nop nop call EN clrf speicher return ;LCD - Daten - Funktion lcd_daten movwf speicher movf speicher,w movwf PORTB bsf RS nop nop call EN swapf speicher,w movwf PORTB bsf RS nop nop call EN clrf speicher return