;********************************************************************* ; Lcd_Out ;Übergabeparameter bei Aufruf der Sub ist zuvor der Pointer in ;das WREG zu kopieren: ;Beispiel: movlw b'00000011 ;2zeilige Ausgabe ; movwf LcdLines_F ; movlw txt_1 ;ab Pointer "txt_1" ; CALL Lcd_Out ;Gebrauch der Subroutine "Lcd_Out": CBLOCK LcdLines_F,w ;flagregister tmp ;Arbeitsvariable pointer tmpLines ,Aktuell auszugebende Zeile ENDC ;Allgemeines ;----------- ;Die Anzahl auszugebender Zeilen wird mit dem Flagregister ; "LcdLines_F" festgelegt: ; LcdLines_F 00000001 = 1zeilige LCD-Ausgabe ; 00000011 = 2zeilige " ; 00001111 = 4zeiliges " ;entsprechende Zeilen müssen dann auch vorhanden sein, wobei der ;Ausgabetext zwar kürzer, aber nicht länger als die Zeilenlänge ;des LCD sein darf. ; ;Beispiel Ausgabetext LCD2x8 ; txt_1 dt 00h,"Hallo ",' '+80h ; 40h,"LCD..2x8",' '+80h ; ;Erläuterung: txt_1 Pointer auf Registeradresse "txt_1" ; dt Direktive "Datentabelle" ; 40h DDRAM-Adresse für Zeile 2 digit 0 ; "LCD..2x8" Ausgabetext ; " " Leerzeichen (ASCII32) ; +80h Marker zum Erkennen Zeilenende ; ;Beispiel Ausgabetext nur in Zeile 2, ab Digit 4 ; dt 44h,"Volt",' '+80h ;--------------------------------------------------------------------- Lcd_Out ; Übergabeparamter Pointer z.B. ; "movlw table_XY" ; "movlw LCD_TYPE" ; "movwf LcdLines_F" ;Bit3:0 Je Bit=1 1 auszugebende LCD-Zeile ; banksel LCD_PORT ;bank0 movwf tmp ;tmp pointer read from table position decf tmp,f ;pointer decr -> incf tmp,F in "Char_Read" movf LcdLines_F,w ;flagregister movwf tmpLines_F ;temporary flagregister ; Lcd_Out_Line rrf tmpLines_F,f ;Zeilenbits über Carry rechtschieben bcf tmpLines_F,7 ;bit7 Carry=1 verhindern btfss STATUS,C ;Carry=0? All lines displayed? GOTO Lcd_Out_0 ;Yes, job is done CALL Char_Read ;No, get DDRAM adress from table (in WREG) iorlw b'10000000' ;function set + DDRAM adress CALL OutLcdControl ;sends instruction to LCD ; Lcd_Out_Char CALL Char_Read ;Pointer+1, next number in table addlw 80h ;+128 marks end of line btfsc STATUS,C ;bit7=1? end of line? GOTO Lcd_Out_Line ;YES, send command DDRAM adress next line andlw 7fh ;NO, +127 restore character CALL OutLcdData ;display character GOTO Lcd_Out_Char ; Char_Read movlw 0x07 ;value to set PCLATH movwf PCLATH ;tables start at page 0x700 incf tmp,f ;pointer to the next number in table movf tmp,w ;copy pointer to WREG movwf PCL ;jumps to adress PCLATH,PCL Lcd_Out_0 ;returns read char/adress in WREG RETURN ;********************************************************************* ;table_POINTER ORG 0x700 ;table in page 7 txt_XY ;Label (used as pointer) dt 00h,"Text5678"," "+80 ;Lcd-Text-Table ; Pointer Literal (movlw txt_XY) wird als Pointer in PCL kopiert ; PCLATH wird in Sub Lcd_Out mit der pageadress (pagesel) geladen ; Format: ; dt |DDRAM-Adr.|, |Ausgabetext|, |' '+80'Marker Zeilenende| ;DDRAM-Adressen ; Zeile 1: 00h Zeile 2: 40h Zeile 3: 14h Zeile 4: 54h ;---------------------------------------------------------------------