I have two relatively short questions, so this is a two parter thread.
Part one:
Assuming I have this code at the top of my program:
Is there any reason why this code gives me something weird:
while this code works as it was intended:
Part Two:
I am using a microcontroller board onto which the PIC, LCD, and the Keypad are mounted and internally connected. I found out that:
That being said, I implement a subroutine to receive a key like this:
where the KPHexToChar table is the following:
As a reference, I have linked the Keypad schematic at the bottom.
My issue is that only the keys in the first row are displayed. When I press the keys 1, 2 3 or A, everything works fine. However, if I press any key which is in the same column as any of the keys I mentioned above, only the respective keys in the first row of that column are displayed on the LCD.
Any help is really appreciated!
https://gyazo.com/df4f2554222fb352236db8c943ea3473
Part one:
Assuming I have this code at the top of my program:
Code:
Code_Char_One equ B'00000011' ;code for keypad A
udata
Code_Sum res 1
Is there any reason why this code gives me something weird:
Code:
movf Code_Char_One
movwf Code_Sum
while this code works as it was intended:
Code:
movlw B'00001011'
Code_Sum res 1
Part Two:
I am using a microcontroller board onto which the PIC, LCD, and the Keypad are mounted and internally connected. I found out that:
The*Microcontroller*implements*a*keypad*module*by*using*a*keypad*encoder*chip,*such*as*MM74C922N.*This*chip*translates*the*key pressed*on*the*4x4*keypad*into*a*4*bit*hex*code*which*would*
be*displayed*on*PORTB4‐7.*
That being said, I implement a subroutine to receive a key like this:
Code:
Read_Key btfss PORTB,1 ;Wait until data is available from the keypad
goto $-1
swapf PORTB,W ;Read PortB<7:4> into W<3:0>
andlw 0x0F
call KPHexToChar ;Convert keypad value to LCD character (value is still held in W)
call WR_DATA ;Write the value in W to LCD
btfsc PORTB,1 ;Wait until key is released
goto $-1
return
where the KPHexToChar table is the following:
Code:
KPHexToChar
addwf PCL,F
dt "123A456B789C*0#D"
As a reference, I have linked the Keypad schematic at the bottom.
My issue is that only the keys in the first row are displayed. When I press the keys 1, 2 3 or A, everything works fine. However, if I press any key which is in the same column as any of the keys I mentioned above, only the respective keys in the first row of that column are displayed on the LCD.
Any help is really appreciated!
https://gyazo.com/df4f2554222fb352236db8c943ea3473