;============================================================
; File name:PIC18F452_LCD_ROUTINE
; Date:
; Author:KGAVIONICS
; Processor:
; Reference circuit:
;============================================================
; Copyright notice:
;============================================================
; Program Description:
;
;===========================
; configuration switches
;===========================
list p=18f452
#include P18F452.INC
CONFIG WDT=OFF; disable watchdog timer
CONFIG DEBUG = OFF; Enable Debug Mode
CONFIG LVP = OFF; Low-Voltage programming disabled (necessary for debugging)
CONFIG OSC = HS;
;=====================================================
; constant definitions
;=====================================================
;=====================================================
; PIC register equates
pcl EQU 2
;=====================================================
;=====================================================
; variables in PIC RAM
;=====================================================
counter1 EQU 01
counter2 EQU 02
number EQU 03
STCOUNT EQU 04
;============================================================
; program
;============================================================
org 0X00 ; start at address
goto main
delay
movlw 0x02
movwf counter2
loop1
movlw 0xff
movwf counter1
loop2
nop
decfsz counter1
goto loop2
decfsz counter2
goto loop1
return
delaylong
movlw 0xff
movwf counter2
loop1l
movlw 0xff
movwf counter1
loop2l
nop
decfsz counter1
goto loop2l
decfsz counter2
goto loop1l
return
instw
PIC movwf PORTB
call delay
bcf PORTD,4
call delay
bsf PORTD,5
call delay
bcf PORTD,5
call delay
return
dataw
movwf PORTB
call delay
bsf PORTD, 4
call delay
bsf PORTD, 5
call delay
bcf PORTD, 5 ;Transitional E signal
call delay
return
DISPLAY
LFSR 2,0X05
A9 MOVF INDF2,W
CALL dataw
INCF FSR2L
DECFSZ STCOUNT,F
BRA A9
MOVLW 0XC0
CALL instw
CALL delay
A10 MOVF INDF2,W
CALL dataw
INCF FSR2L
MOVF INDF2,W
BNZ A10
RETURN
main:
movlw 0x00
movwf TRISB
movwf TRISD
clrf PORTD
clrf PORTB
call delay
call delay
start
clrf PORTD ;Here RW is pulled down to ground
;LCD routine starts
call delay
;give LCD module to reset automatically
;Fundtion for 8-bit, 2-line display, and 5x8 dot matrix
movlw 0x38
call instw
call delay
movlw b'00001000' ; display off, cursor off, blink off
call instw
call delay
movlw b'00001100';display on
call instw
call delay
movlw b'00000001' ; clear display
call instw
call delay
movlw b'00000110' ; increment, no display shift
call instw
call delay
MOVLW 0X10
MOVWF STCOUNT
LFSR 2,0X05
LFSR 1,0X05
MOVLW 0X0
MOVWF TBLPTRL ; LOOK UP TABLE LOW BYTE ADRESS
MOVLW 0X02
MOVWF TBLPTRH ; LOOK UP TABLE HIGH BYTE ADRESS
B7 TBLRD* ;TABLAT POINT TOWARD THE FIRST STRING
MOVF TABLAT,W ; COPY CHAR TO W
BZ EXIT
MOVWF INDF1,0
INCF FSR1L,F
INCF TBLPTRL,F
BRA B7
EXIT
CALL DISPLAY
KAIS GOTO KAIS
ORG 0X200
MYDATA DB " PIC18F452 ***LCD DEMO*** " ,0
END
;============================================================
end ; END OF PROGRAM
;============================================================