The defaults setings are
- Keypad ROW are connected to PORTB<3:0>
- Keypad COL are connected to PORTB<7:4>
- Debounce delay = 200 mSec
- No auto-repeat
- Keypad type 4X4
INCLUDE "KeyPad.bas" myvar var byte start: @ READKEYPAD _myvar hserout ["Key=",dec myvar,13,10] goto start
If you decide to change default settings, here's the DEFINEs list
DEFINE KEYPAD_ROW 4 ' 4 ROW keypad DEFINE KEYPAD_ROW_PORT PORTB ' ROW port = PORTB DEFINE KEYPAD_ROW_BIT 4 ' ROW0 = PORTB.4 DEFINE KEYPAD_COL 4 ' 4 COL keypad DEFINE KEYPAD_COL_PORT PORTB ' COL port = PORTB DEFINE KEYPAD_COL_BIT 0 ' COL0 = PORTB.0 DEFINE KEYPAD_DEBOUNCEMS 200 ' debounce delay = 200 mSec DEFINE KEYPAD_AUTOREPEAT 1 ' use auto-repeat feature
Code example #2: Using a 8X4 keypad
INCLUDE "KeyPad.bas" ' ' Hardware connection ' =================== DEFINE KEYPAD_ROW 8 ' 8 row define KEYPAD_ROW_PORT PORTB ' on PORTB DEFINE KEYPAD_ROW_BIT 0 ' <7:0> DEFINE KEYPAD_COL 4 ' 4 col DEFINE KEYPAD_COL_PORT PORTA ' on PORTA DEFINE KEYPAD_COL_BIT 0 ' <3:0> DEFINE KEYPAD_DEBOUNCEMS 200 ' debounce delay = 200 mSec define KEYPAD_AUTOREPEAT 1 ' use auto-repeat ' ' Serial Communication definition ' =============================== DEFINE HSER_TXSTA 24h ' enable transmit, BRGH=1 DEFINE HSER_SPBRG 129 ' 9600 Bauds ' ' Variables definition ' =================== myvar var byte ' ---------------------------------[Program Start]---------------------------------------------- start: @ READKEYPAD _myvar hserout ["Key=",dec myvar,13,10] goto start
Everything is explain in the attach file... don't forget to rename it

Remapping keys:
Darrel gave this answer in the thread below for re-mapping keys on the keypad. This shows reversing key order, but any key order (or dis-order) will do using the lookup function.
@ READKEYPAD _myvar ; original keys 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 LOOKUP myvar,[0,16,15,14,13,12,11,10,9,8, 7, 6, 5, 4, 3, 2, 1],myvar
Re: K42 and Timer Interrupts
Thanks for the explanation.
Ioannis - 28th April 2025, 19:28I misinterpreted these paragraphs. My understanding was to have ASYNC cleared and use Fosc/4.
Ioannis