Matrix Keypad routine


Results 1 to 40 of 135

Threaded View

  1. #16
    Join Date
    Oct 2008
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    Hay guys and girls. I've been playing around with this coding this afternoon and i keep getting errors and when i dont nothing going as i thought it should so any chance somone could point out whats wrong please or point me in the right dirrection at least!

    My main coding:

    Code:
    TRISA=%00000011
    TRISB=%00000000
    TRISC=%11111110
    ADCON0=%11000000
    ADCON1=%00000111 
    INCLUDE "KeyPad.bas"         
    
        '                      
        '    Hardware connection
        '    ===================
        DEFINE KEYPAD_ROW        8       ' 8 row 
        define KEYPAD_ROW_PORT   PORTc   '   on PORTB
        DEFINE KEYPAD_ROW_BIT    0       '      <7:0>
        DEFINE KEYPAD_COL        4       ' 4 col 
        DEFINE KEYPAD_COL_PORT   PORTc   '   on PORTA
        DEFINE KEYPAD_COL_BIT    0       '      <3:0>
        DEFINE KEYPAD_DEBOUNCEMS 200     ' debounce delay = 200 mSec
        define KEYPAD_AUTOREPEAT 1       ' use auto-repeat
    ' LCD Display
    ' -----------
    ' Adjust these to suit your chosen LCD pinout
    '
    DEFINE LCD_DREG PORTb 			'Define PIC port used for LCD Data lines
    DEFINE LCD_DBIT 4 			'Define first pin of portb connected to LCD DB4
    DEFINE LCD_RSREG PORTb 			'Define PIC port used for RS line of LCD
    DEFINE LCD_RSBIT 3 			'Define Portb pin used for RS connection
    DEFINE LCD_EREG PORTb 			'Define PIC prot used for E line of LCD
    DEFINE LCD_EBIT 0 			'Define PortB pin used for E connection
    DEFINE LCD_BITS 4 			'Define the 4 bit communication mode to LCD
    DEFINE LCD_LINES 2 			'Define using a 2 line LCD
    DEFINE LCD_COMMANDUS 2000 		'Define delay between sending LCD commands
    DEFINE LCD_DATAUS 50 			'Define delay time between data sent.
        
        '
        '    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]
    	gosub lcddisp
        goto start
    
    lcddisp:
    LCDOUT $FE, 1, myvar
    pause 60
    return
    end

    The modified Keypad code
    Code:
    TRISA=%00000011
    TRISB=%00000000
    TRISC=%11111110
    ADCON0=%11000000
    ADCON1=%00000111 
    INCLUDE "KeyPad.bas"         
    
        '                      
        '    Hardware connection
        '    ===================
        DEFINE KEYPAD_ROW        8       ' 8 row 
        define KEYPAD_ROW_PORT   PORTc   '   on PORTB
        DEFINE KEYPAD_ROW_BIT    0       '      <7:0>
        DEFINE KEYPAD_COL        4       ' 4 col 
        DEFINE KEYPAD_COL_PORT   PORTc   '   on PORTA
        DEFINE KEYPAD_COL_BIT    0       '      <3:0>
        DEFINE KEYPAD_DEBOUNCEMS 200     ' debounce delay = 200 mSec
        define KEYPAD_AUTOREPEAT 1       ' use auto-repeat
    ' LCD Display
    ' -----------
    ' Adjust these to suit your chosen LCD pinout
    '
    DEFINE LCD_DREG PORTb 			'Define PIC port used for LCD Data lines
    DEFINE LCD_DBIT 4 			'Define first pin of portb connected to LCD DB4
    DEFINE LCD_RSREG PORTb 			'Define PIC port used for RS line of LCD
    DEFINE LCD_RSBIT 3 			'Define Portb pin used for RS connection
    DEFINE LCD_EREG PORTb 			'Define PIC prot used for E line of LCD
    DEFINE LCD_EBIT 0 			'Define PortB pin used for E connection
    DEFINE LCD_BITS 4 			'Define the 4 bit communication mode to LCD
    DEFINE LCD_LINES 2 			'Define using a 2 line LCD
    DEFINE LCD_COMMANDUS 2000 		'Define delay between sending LCD commands
    DEFINE LCD_DATAUS 50 			'Define delay time between data sent.
        
        '
        '    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]
    	gosub lcddisp
        goto start
    
    lcddisp:
    LCDOUT $FE, 1, myvar
    pause 60
    return
    end



    forgot to put the error code

    Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F876A "KEYPADTE.ASM" /l"KEYPADTE.lst" /e"KEYPADTE.err"
    Error[113] C:\PBP\PBPPIC14.LIB 2784 : Symbol not previously defined (PORTb)
    Error[113] C:\PBP\PBPPIC14.LIB 2785 : Symbol not previously defined (PORTb)
    Error[113] C:\PBP\PBPPIC14.LIB 2789 : Symbol not previously defined (PORTb)
    Error[113] C:\PBP\PBPPIC14.LIB 2790 : Symbol not previously defined (PORTb)
    Error[113] C:\PBP\PBPPIC14.LIB 2800 : Symbol not previously defined (PORTb)
    Error[113] C:\PBP\PBPPIC14.LIB 2871 : Symbol not previously defined (PORTb)
    Error[113] C:\PBP\PBPPIC14.LIB 2889 : Symbol not previously defined (PORTb)
    Error[113] C:\PBP\PBPPIC14.LIB 2913 : Symbol not previously defined (PORTb)
    Error[113] C:\PBP\PBPPIC14.LIB 2920 : Symbol not previously defined (PORTb)
    Error[113] C:\PBP\PBPPIC14.LIB 2928 : Symbol not previously defined (PORTb)
    Error[113] C:\PBP\PBPPIC14.LIB 2934 : Symbol not previously defined (PORTb)
    Error[113] C:\PBP\KEYPADTE.ASM 100 : Symbol not previously defined (PORTc)
    Error[113] C:\PBP\KEYPADTE.ASM 103 : Symbol not previously defined (PORTc)
    Error[113] C:\PBP\KEYPADTE.ASM 125 : Symbol not previously defined (PORTc)
    Error[113] C:\PBP\KEYPADTE.ASM 136 : Symbol not previously defined (PORTc)
    Halting build on first failure as requested.
    BUILD FAILED: Thu Nov 20 16:00:57 2008
    Attached Images Attached Images  
    Last edited by chrisshortys; - 20th November 2008 at 17:45.

Similar Threads

  1. calculator-like code entry with matrix keypad and display
    By Dennis in forum mel PIC BASIC Pro
    Replies: 35
    Last Post: - 16th December 2009, 22:58
  2. Need help in matrix keypad coding
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 24th May 2008, 13:16
  3. I2C PCF8574 4X4 Keypad routine
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th January 2007, 21:25
  4. Inconsistent output on a 4x4 matrix keypad
    By markcadcam in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 24th November 2006, 03:54
  5. very basic matrix keypad question
    By kitcat in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th July 2006, 21:33

Members who have read this thread : 2

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