; Oscillator Selection:
CONFIG FOSC = XT_XT ;XT oscillator, XT used by USB
CBLOCK 0x000
d1
d2
d01
ENDC
;******************************************************************************
;Reset vector
; This code will start executing when a reset occurs.
ORG 0x0000
goto Main ;go to start of main code
strobe macro ;strobes the E pin
BSF PORTA,2
NOP
NOP
NOP
NOP
BCF PORTA,2
endm
cmd macro ;SetsRS high for cmd
BSF PORTA,3
nop
nop
endm
cmd_end macro ; SetsRS low for data
BCF PORTA,3
NOP
NOP
endm
Main:
CLRF LATA ; Alternate method
; to clear output
; data latches
MOVLW 0Fh ; Configure A/D
MOVWF ADCON1 ; for digital inputs
MOVLW 07h ; Configure comparators
MOVWF CMCON ; for digital input
MOVLW 0x00 ; Value used to
; initialize data
; direction
MOVWF TRISA ; all as outputs
CLRF LATB ; Alternate method
; to clear output
; data latches
MOVLW 0Eh ; Set RB<4:0> as
MOVWF ADCON1 ; digital I/O pins
; (required if config bit
; PBADEN is set)
MOVLW 0x00 ; Value used to
; initialize data
; direction
MOVWF TRISB ; Set all to output
GOTO LCD_Start
LCD_Start: ;startup your LCD and make it blink
call ST_Delay
cmd ; sets LCD for for command
MOVLW b'00001111' ;loads cmd data
MOVWF PORTB ;puts it out on the data port
strobe ; tells the LCD come and get the command data
call DATCMDelay
cmd_end ;Sets to send data
MOVLW b'0011000' ;puts it out on the data port
MOVWF PORTB
strobe ; tells the LCD come and get the command data
GOTO Wait
Wait: ;hang out here so you can see the LCD print a 0
GOTO Wait
DATCMDelay
;496 cycles
movlw 0xA5
movwf d01
DATCMD_0
decfsz d01, f
goto DATCMD_0
;4 cycles (including call)
return
ST_Delay
;4993 cycles
movlw 0xE6
movwf d1
movlw 0x04
movwf d2
ST_Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto ST_Delay_0
;3 cycles
goto $+1
nop
;4 cycles (including call)
return
end