Keypad and DT's Instant Interrupts


Results 1 to 12 of 12

Threaded View

  1. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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
    Code:
    <font color="#000000">    @       __CONFIG _XT_OSC &amp; _LVP_OFF
        
        <font color="#000080">INCLUDE </font>&quot;C:\PBP_PROG\INCLUDE_ROUTINES\KeyPad.bas&quot;
        <font color="#000080">INCLUDE </font>&quot;c:\PBP_PROG\EASYPIC4\LCD4.bas&quot;  
        <font color="#000080">INCLUDE </font>&quot;C:\PBP_PROG\INCLUDE_ROUTINES\DT_INTS-14.bas&quot;
        <font color="#000080">INCLUDE </font>&quot;C:\PBP_PROG\INCLUDE_ROUTINES\ReEnterPBP.bas&quot;            
        
        <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,&quot;PRESS ANY KEY&quot;
    
        @ INT_ENABLE  TMR0_INT
    
    Start:
        <font color="#000080">IF </font>ByteA <font color="#000080">THEN 
            LCDOUT </font>$FE,$C0,<font color="#000080">REP </font>&quot; &quot;\2,$FE,$C0, <font color="#000080">DEC </font>ByteA
            <font color="#000080">ENDIF
        GOTO </font>Start
        
    
    TMR0Interrupt:
        @ READKEYPAD _ByteA
        TMR0=0
        @ INT_RETURN
    and it's still working.

    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.
    Last edited by mister_e; - 26th April 2007 at 16:13.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts