using the previous but changing KEYPAD_ROW or KEYPAD_COL number it always work for me. Yeah, even a 1X1 keypad work... wooohoo how handy it is
Now, using a TIMER0 interrupt and DT-INT14, it looks like
and it's still working.Code:<font color="#000000"> @ __CONFIG _XT_OSC & _LVP_OFF <font color="#000080">INCLUDE </font>"C:\PBP_PROG\INCLUDE_ROUTINES\KeyPad.bas" <font color="#000080">INCLUDE </font>"c:\PBP_PROG\EASYPIC4\LCD4.bas" <font color="#000080">INCLUDE </font>"C:\PBP_PROG\INCLUDE_ROUTINES\DT_INTS-14.bas" <font color="#000080">INCLUDE </font>"C:\PBP_PROG\INCLUDE_ROUTINES\ReEnterPBP.bas" <font color="#000080">DEFINE </font>KEYPAD_ROW 4 <font color="#008000">' 4 ROW keypad </font><font color="#000080">DEFINE </font>KEYPAD_ROW_PORT PORTB <font color="#008000">' ROW port = PORTB </font><font color="#000080">DEFINE </font>KEYPAD_ROW_BIT 4 <font color="#008000">' ROW0 = PORTB.4 </font><font color="#000080">DEFINE </font>KEYPAD_COL 3 <font color="#008000">' 4 COL keypad </font><font color="#000080">DEFINE </font>KEYPAD_COL_PORT PORTB <font color="#008000">' COL port = PORTB </font><font color="#000080">DEFINE </font>KEYPAD_COL_BIT 1 <font color="#008000">' COL0 = PORTB.0 </font><font color="#000080">DEFINE </font>KEYPAD_DEBOUNCEMS 20 <font color="#008000">' debounce delay = 20 50 mSec </font><font color="#000080">DEFINE </font>SCAN_ONCE 1 <font color="#000080">ASM INT_LIST macro INT_Handler TMR0_INT, _TMR0Interrupt, PBP, yes endm INT_CREATE ENDASM </font>OPTION_REG=%00000100 <font color="#008000">' Enable weak-pull ups </font> <font color="#008000">' Prescaler assigned to Timer0 </font> <font color="#008000">' rate 1:32 </font>ByteA <font color="#000080">VAR BYTE </font>TMR0IF <font color="#000080">VAR </font>INTCON.2 <font color="#000080">PAUSE </font>500 <font color="#000080">LCDOUT </font>$FE,1,"PRESS ANY KEY" @ INT_ENABLE TMR0_INT Start: <font color="#000080">IF </font>ByteA <font color="#000080">THEN LCDOUT </font>$FE,$C0,<font color="#000080">REP </font>" "\2,$FE,$C0, <font color="#000080">DEC </font>ByteA <font color="#000080">ENDIF GOTO </font>Start TMR0Interrupt: @ READKEYPAD _ByteA TMR0=0 @ INT_RETURN
do a I/O test with LEDs and push button to see if there's any faulty.
KEYPAD_COL 3 really set the KeyPAd to 3 column, DEFINE KEYPAD_COL_BIT 1 will imply you're connected to PORTB.1, PORTB.2, PORTB.3
same for rows, DEFINE KEYPAD_ROW 4, 4 rows, DEFINE KEYPAD_ROW_BIT 4, so PORTB.4, PORTB.5, PORTB.6 and PORTB.7.





Bookmarks