kutalinelucas
New Member
i was wondering if somebody could help me with this.
I have a program which reads port a, and takes a valid signal when one of the concurrently held keys is released. the problem i have is i want the program to compaire the value to a number of possibilities, and im not sire where im going wrong. any help would be greatly appriciated.
cheers.
I have a program which reads port a, and takes a valid signal when one of the concurrently held keys is released. the problem i have is i want the program to compaire the value to a number of possibilities, and im not sire where im going wrong. any help would be greatly appriciated.
cheers.
Code:
WaitNoKey call Delay10 ;required for debounce
movfw SWITCH_PORT ;get keys
movwf tmp1
comf tmp1, W
andlw 0x3f ;keep only bottom 5 bits !!NEED TO CHANGE THIS LINE!!
btfss STATUS,Z ;are any keys pressed
goto WaitNoKey ;yes, so carry on waiting
clrf Keys ;indicate no key pressed
WaitValid call Delay10 ;wait 10mS for debounce
movfw Keys ;gets keys from last time
movwf OldKeys ;keep copy for later
movfw SWITCH_PORT ;get new key state
movwf tmp2
comf tmp2, w
andlw 0x3f ;keep only bottom 5 bits
movwf Keys ;save for next time around
xorwf OldKeys,w ;keep only keys that have changed
andwf OldKeys,w ;and were pressed last time around
btfsc STATUS,Z ;will be non zero if a key was released
goto WaitValid
movfw OldKeys ;contains the valid key combination
movwf validkeypress ;store valid keypress in reg,., port was inverted so should act like active low
call checkchar
waitnopress movfw SWITCH_PORT ;= skip if set ;) - z set if theres a match
xorlw 0x3f ;bit mask with 111111
btfss STATUS, Z ;so if there is a match, and no buttons are pressed, z is set
goto waitnopress ;skips the next instruction and goes back to the beginning.......
goto WaitNoKey
checkchar movF PUSH_B
xorwf validkeypress ;here the valid press should be active high, because of the comf. ;
btfsc STATUS, Z ;skip next instruction if there is no match
call Outputa
retlw 0x00
;;;here i want it to cycle through and compaire the read value to a number of stored values, and act accordingly,
Outputa
movlw 0x00
call Text_A ;get a character from the text table
call LCD_Char ;here after it returns a 0x00, it goes back to loop - not good. ; call Delay10
incf countchar,
clrf SWITCH_PORT
retlw 0x00