;****************************************************************************** ; * ; Filename: hb16102_fkt.asm * ; Date: 19.04.2007 * ; File Version: 0.1 * ; * ; Author: Thomas Fuchs * ; comment: funktionen des displays * ; * ; Anschluss des Displays: * ; C0: 4, RS * ; C1: 6, EN * ; D0 - D7: Data 0 bis Data 7 * ;****************************************************************************** ; * ; Files required: P18F4685.INC * ; * ;****************************************************************************** LIST P=18F4685 ;directive to define processor #include ;processor specific variable definitions ;****************************************************************************** ;Configuration bits ; Oscillator Selection: CONFIG OSC=IRCIO7 ;intern CONFIG WDT=OFF ;no Watchdog CONFIG CP0=OFF,CP1=OFF,CP2=OFF ;code protect off CONFIG CP3=OFF,CP4=OFF,CP5=OFF,CPB=OFF,CPD=OFF CONFIG WRT0=OFF,WRT1=OFF,WRT2=OFF,WRT3=OFF,WRT4=OFF,WRT5=OFF CONFIG WRTB=OFF,WRTC=OFF,WRTD=OFF CONFIG PBADEN=OFF ;Port A as I/O CONFIG LVP=OFF ;low voltage programming ;****************************************************************************** ;Variable definitions UDATA WREG_TEMP ;variable used for context saving STATUS_TEMP ;variable used for context saving BSR_TEMP ;variable used for context saving UDATA_ACS lcddata RES 1 ;8bit zwischenspeicher: daten/cmd an gLCD adrLSB RES 1 ;8bit zwischenspeicher: address LSB adrMSB RES 1 ;8bit zwischenspeicher: address MSB rows RES 1 ;8bit zwischenspeicher: rows (text) lines RES 1 ;8bit zwischenspeicher: lines (text) loop RES 1 ;warten in ms loopcali RES 1 ;zeahlvar fuer wait_1ms ;****************************************************************************** ;Reset vector ; This code will start executing when a reset occurs. ORG 0x0000 goto Main ;go to start of main code ;****************************************************************************** ;Start of main program ; The main program code is placed here. Init: movlw 0x70 ; maximale interne Frequenz 8MHz (cyc. = 0,5µs) setzen movwf OSCCON movlw 0x07 movwf CMCON movlw 0x0F movwf ADCON1 clrf WREG ; Akkumulator loeschen movwf TRISD ; PortD als Ausgang definieren movwf TRISC ; PortC als Ausgang definieren movwf TRISB ; PortB als Ausgang definieren rcall set_display rcall clear_display return Main: ; *** main code goes here *** ORG 0x0100 movlw D'150' movwf loop rcall waitxms rcall Init ;Initialisieren Main_: movlw 0x03 ;home addr movwf lcddata rcall write_cmd movlw D'2' movwf loop rcall waitxms movlw 0x42 ;write B rcall write_char movlw 0x6C ;write l rcall write_char movlw 0x75 ;write u rcall write_char movlw 0x62 ;write b rcall write_char movlw 0x62 ;write b rcall write_char movlw D'50' movwf loop rcall waitxms movlw 0xC0 ;Startadresse 2. Zeile rcall set_address movlw 0x21 ;write ! rcall write_char goto Main_ return set_display: movlw 0x0C ;display on movwf lcddata rcall write_cmd movlw 0x0B movwf loopcali rcall wait_4mues movlw 0x38 ;2 lines movwf lcddata rcall write_cmd movlw 0x0B movwf loopcali rcall wait_4mues return write_cmd: bcf LATC,0 ; command goto write_data1 ; same code write_data: bsf LATC,0 ; data write_data1: bsf LATC,1 ; enable chip movff lcddata, LATD ; write nop bcf LATC,1 ; disable chip return write_char: movwf lcddata rcall write_data movlw 0x0B movwf loopcali rcall wait_4mues return set_address: movwf lcddata rcall write_cmd movlw 0x0A movwf loopcali rcall wait_4mues return clear_display: movlw 0x01 ;clear display movwf lcddata rcall write_cmd movlw 0x0A movwf loopcali rcall wait_4mues return waitxms: rcall wait_1ms decf loop bnz waitxms return wait_1ms: movlw 0xF9 movwf loopcali wait_4mues: decf loopcali nop nop nop nop nop bnz wait_4mues return ;****************************************************************************** ;End of program END