; Oscillator Selection:
CONFIG OSC = INTIO67
CONFIG WDT = OFF
CONFIG MCLRE = ON
CONFIG PBADEN = off
CONFIG LVP = off
;******************************************************************************
;Variable definitions
; These variables are only needed if low priority interrupts are used.
; More variables may be needed to store other special function registers used
; in the interrupt routines.
; UDATA
preston EQU 0x20
zach EQU 0x30
prestonj EQU 0x50
zachj EQU 0x40
translate EQU 0x60
cblock 0x10
counta
countb
countc
test
endc
#define c1 PORTB,0
#define c2 PORTB,1
#define c3 PORTB,2
#define r1 PORTB,3
#define r2 PORTB,4
#define r3 PORTB,5
#define r4 PORTB,6
#define RS PORTD,0
#define RW PORTD,1
#define EN PORTD,2
; UDATA_ACS
;EXAMPLE RES 1 ;example of a variable in access RAM
;******************************************************************************
;Reset vector
; This code will start executing when a reset occurs.
RESET_VECTOR CODE 0x0000
goto Main ;go to start of main code
;******************************************************************************
;Start of main program
; The main program code is placed here.
Main:
movlw 0x0A
movwf ADCON1
movlw 0x0A
movwf CMCON
call init
call scan_main
scan_main
call scan1 ;subroutines for keypad to check/display
call scan2 ;
call scan3 ;
goto scan_main
init
clrf PORTB
clrf PORTD ;
clrf PORTC ;setting up PORTD/PORTC/PORTB
clrf TRISC ;as output
clrf TRISD ;
clrf TRISB ;
movlw 0xF8
movwf TRISB ;setting portb as output(column) and input(rows)
bcf RS ;clearing R/S and R/W
bcf RW ;
movlw 0x38 ;initializing
movwf PORTC ;LCD
call toggle
movlw 0x38
movwf PORTC ;
call toggle
movlw 0x38
movwf PORTC ;
call toggle
movlw 0x0F ;setting up display and cursor
movwf PORTC
call toggle
movlw 0x14 ;turn on display and direction of cursor
movwf PORTC
call toggle
movlw 0x01 ;clear display
movwf PORTC
call toggle
movlw 0x06 ;character entry mode
movwf PORTC
call toggle
bsf RS
zach_japanese
movlw 0xBB ;loading cblock with
movwf 0x41 ;with hex values for
movlw 0xDE ;characters
movwf 0x42
movlw 0xAF
movwf 0x43
movlw 0xB8
movwf 0x44
preston_japanese
movlw 0xCD
movwf 0x51
movlw 0xDF
movwf 0x52
movlw 0xDA
movwf 0x53
movlw 0xBD
movwf 0x54
movlw 0xC4
movwf 0x55
movlw 0xDD
movwf 0x56
zach_english
movlw 'Z'
movwf 0x31
movlw 'a'
movwf 0x32
movlw 'c'
movwf 0x33
movlw 'h'
movwf 0x34
preston_english
movlw 'P'
movwf 0x21
movlw 'r'
movwf 0x22
movlw 'e'
movwf 0x23
movlw 's'
movwf 0x24
movlw 't'
movwf 0x25
movlw 'o'
movwf 0x26
movlw 'n'
movwf 0x27
translate?pushAsterisk
movlw 'T'
movwf 0x61
movlw 'r'
movwf 0x62
movlw 'a'
movwf 0x63
movlw 'n'
movwf 0x64
movlw 's'
movwf 0x65
movlw 'l'
movwf 0x66
movlw 'a'
movwf 0x67
movlw 't'
movwf 0x68
movlw 'e'
movwf 0x69
movlw '?'
movwf 0x6A
movlw ' '
movwf 0x6B
movlw 'P'
movwf 0x6C
movlw 'u'
movwf 0x6D
movlw 's'
movwf 0x6E
movlw 'h'
movwf 0x6F
movlw ' '
movwf 0x70
movlw '*'
movwf 0x71
return
scan3
bsf c3 ;sending a hi to column3
btfsc r1 ;checking row 1
call asterisk ;translate subroutine
call delay
btfsc r2 ;checking row 2
call seven ;7 display subroutine
call delay
btfsc r3 ;checking row 3
call four ;4 display subroutine
call delay
btfsc r4 ;checking row 4
call one ;1 display subroutine
call delay
bcf c3 ;clear column3 to check other columns
return
scan2
bsf c2 ;sending a hi to column3
btfsc r1 ;checking row 1
call zero ;0 display subroutine
call delay
btfsc r2 ;checking row 2
call eight ;8 display subroutine
call delay
btfsc r3 ;checking row 3
call five ;5 display subroutine
call delay
btfsc r4 ;checking row 4
call two ;2 display subroutine
call delay
bcf c2 ;sending a low to column2 to check other columns
return
scan1
bsf c1 ;sending a hi to column1
btfsc r1 ;checking row 4
call pound ;clear display subroutine
call delay
btfsc r2 ;checking row 4
call nine ;9 display subroutine
call delay
btfsc r3 ;checking row 4
call six ;6 display subroutine
call delay
btfsc r4 ;checking row 4
call three ;3 display subroutine
call delay
bcf c1 ;sending a low to column1 to check other column
return
one
call prestonE_set
call translate_set
return
two
call zachE_set
call translate_set
return
three
call prestonj_set
call translate_set
return
four
call zachj_set
call translate_set
return
five
movlw '5' ;subroutine displays 5 on LCD
movwf PORTC
call toggle
return
six
movlw '6' ;subroutine displays 6 on LCD
movwf PORTC
call toggle
return
seven
movlw '7' ;subroutine displays 7 on LCD
movwf PORTC
call toggle
return
eight
movlw '8' ;subroutine displays 8 on LCD
movwf PORTC
call toggle
return
nine
movlw '9' ;subroutine displays 9 on LCD
movwf PORTC
call toggle
return
zero
movlw '0' ;subroutine displays 0 on LCD
movwf PORTC
call toggle
return
pound ;Clear LCD
bcf RS ;subroutine clears the LCD
movlw 0x01
movwf PORTC
call toggle
return
asterisk
bcf RS
movlw 0x094
movwf PORTC
call toggle
bsf RS
movlw 'G'
movwf PORTC
call toggle
;**read whats at that address(change portC to input?)
;cpfseq 0x21 ;checking for Preston in english
;goto Ast1
;**move to line 3
;Ast1
; cpfseq 0x51 ;checking for Preston in japanese
;goto Ast2
; **move to line 3
;Ast2
; cpfseq 0x31 ;checking for Zach in english
; goto Ast3
; **move to line 3
;Ast3
; cpfseq 0x41 ;checking for Zach in Japanese
; return
; **move to line 3
return
; *****EXTENSIVELY USED SUBROUTINES*****
port_set1
bcf RW
bcf RS
clrf PORTC
clrf TRISC
movlw 0x090
movwf PORTC
call toggle
call prestonj_set
return
port_set
bcf RW
bcf RS
clrf PORTC
clrf TRISC
bsf RS
movlw 'B'
movwf PORTC
call toggle
return
toggle
bsf EN ;set Enable high
call delay
bcf EN ;set Enable low to write letter
call delay
return
zachE_set
movlw 0x04
movwf test
lfsr 0,zach ;setting pointer to send letter to LCD
bcf RW
bsf RS ;setting R/S to allow characters to be written
zachE_name
incf FSR0L,1 ;increment to next location
movff INDF0,PORTC ;moving pointer value to PortC
call toggle
call delay
decfsz test
goto zachE_name ;First name
return
zachj_set
movlw 0x04
movwf test
lfsr 0,zachj ;setting pointer to send letter to LCD
bcf RW
bsf RS ;setting R/S to allow characters to be written
zachj_name
incf FSR0L,1 ;increment to next location
movff INDF0,PORTC ;moving pointer value to PortC
call toggle
call delay
decfsz test
goto zachj_name ;First name
return
prestonE_set
movlw 0x07
movwf test
lfsr 0,preston ;setting pointer to send letter to LCD
bcf RW
bsf RS ;setting R/S to allow characters to be written
prestonE_name
incf FSR0L,1 ;increment to next location
movff INDF0,PORTC ;moving pointer value to PortC
call toggle
call delay
decfsz test
goto prestonE_name ;First name
return
prestonj_set
movlw 0x06
movwf test
lfsr 0,prestonj ;setting pointer to send letter to LCD
bcf RW
bsf RS ;setting R/S to allow characters to be written
prestonj_name
incf FSR0L,1 ;increment to next location
movff INDF0,PORTC ;moving pointer value to PortC
call toggle
call delay
decfsz test
goto prestonj_name ;First name
return
translate_set
bcf RS
movlw 0x40
movwf PORTC
call toggle
movlw 0x0C0
movwf PORTC
call toggle
movlw 0x11
movwf test
lfsr 0,translate ;setting pointer to send letter to LCD
bcf RW
bsf RS ;setting R/S to allow characters to be written
translate_name
incf FSR0L,1 ;increment to next location
movff INDF0,PORTC ;moving pointer value to PortC
call toggle
call delay
decfsz test
goto translate_name ;First name
return
delay
movlw 0x0f
movwf countc
movlw 0x2f
movwf countb
; movlw 0x02
; movwf counta
loop
; decfsz counta,1
; goto loop
decfsz countb,1
goto loop
decfsz countc,1
goto loop
return