;------------------------------------------------------------------------------- ;----------------------------- LCD Initialisation ---------------------------- ;------------------------------------------------------------------------------- LCDinit call d50ms ;Function Set movlw 00111000b ;8-bit mode, 2 lines, 5x7 matrix call LCDinst ;Display on / off movlw 00001100b ;Display on, Cursor off, Blink off call LCDinst ;Entry Mode Set movlw 00000110b ;Increment, Display shifted call LCDinst ;Cursor or display shift movlw 00010000b ;Display Shift call LCDinst ;Clear Screen movlw 00000001b ; Clear screen call LCDinst return ;------------------------------------------------------------------------------- ;----------------------------- LCD Character Send ---------------------------- ;------------------------------------------------------------------------------- LCDsend movlb d'15' ; Ensure BSR is FSR banking bsf LCDrs ; Data mode bcf LCDrw ; Write mode call sndt ; Send data return ;------------------------------------------------------------------------------- ;---------------------------- LCD Instruction Send --------------------------- ;------------------------------------------------------------------------------- LCDinst movlb d'15' ; Ensure BSR is FSR banking bcf LCDrs ; Instruction mode bcf LCDrw ; Write mode call sndt ; Send data call d50ms return ;------------------------------------------------------------------------------- ;--------------------------------- LCD Status ------------------------------- ;------------------------------------------------------------------------------- sndt movwf LATD, 1 ; Place into LCD bus nop bsf LCDen nop nop nop bcf LCDen goto micro100 ;------------------------------------------------------------------------------- ;------------------------------ Delay Routines ------------------------------- ;------------------------------------------------------------------------------- delay movlw d'100' ; 125ns 1 second delay movwf b0_temp3, 0 ; 125ns nop ; 125ns label_3 movlw d'40' ; 125ns movwf b0_temp2, 0 ; 125ns nop ; 125ns nop ; 125ns label_1 movlw d'249' ; 125ns movwf b0_temp, 0 ; 125ns nop ; 125ns nop ; 125ns label_2 nop ; 125ns nop ; 125ns nop ; 125ns nop ; 125ns nop ; 125ns decfsz b0_temp, f, 0 ; 125ns goto label_2 ; 250ns (1us total inner loop) ; 125ns decfsz b0_temp2, f, 0 ; 125ns goto label_1 ; 250ns ; 125ns decfsz b0_temp3, f, 0 ; 125ns goto label_3 ; 250ns return d50ms movlw d'1' ; 50ms delay movwf b0_temp3, 0 goto label_3 micro100 movlw d'100' ; 100us delay movwf b0_temp, 0 label_4 nop ; 125ns nop ; 125ns nop ; 125ns nop ; 125ns nop ; 125ns decfsz b0_temp, f, 0 ; 125ns goto label_4 ; 250ns (1us total inner loop) return end