18F4550 and keypad


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2006
    Location
    Venezuela - Caracas
    Posts
    48

    Default 18F4550 and keypad

    i working with 18F4550 with 4mhz resonator
    usb work 100%
    keypad don't work
    can i help ?

    Code:
       INCLUDE "modedefs.bas"
       INCLUDE "KeyPad.bas"
       
       DEFINE   OSC            48   
       
       DEFINE KEYPAD_ROW        6        ' 4 ROW keypad       
       DEFINE KEYPAD_ROW_PORT   PORTB    ' ROW port
       DEFINE KEYPAD_ROW_BIT    2        ' ROW0
    
       DEFINE KEYPAD_COL        3        ' 4 COL keypad
       DEFINE KEYPAD_COL_PORT   PORTD    ' COL port
       DEFINE KEYPAD_COL_BIT    5        ' COL0
    
       DEFINE KEYPAD_DEBOUNCEMS 200      ' debounce delay = 200 mSec
       DEFINE KEYPAD_AUTOREPEAT 0        ' use auto-repeat feature 
    
       Led                Var	  PORTA.0
       RF_Entrada         VAR    PORTA.1
       
       Contador           Var	  Byte
       Dados              var	  Byte[10]
       Recebeu            var    byte[4]
             
       Acao               var    byte
       Botao              VAR    Byte
       Linha              VAR    BYTE
       Coluna             VAR    BYTE
    
    '-------------------------------------------------------------------------------      
    Configura:
       ADCON0 = 0           ' Turn off A/D
       ADCON1 = 7           ' Set PORTA to digital
       CMCON  = 7           ' Comparators off
    
       high LED   
       PAUSE 100
       
       USBInit
       PAUSE 5000
    	
       Low LED
    
    '-------------------------------------------------------------------------------
    Inicio:
       USBService
       
       contador = 1
    	USBIn 3, Dados, contador, Inicio
    	Toggle LED
    
       iF Dados[0]="B" tHEN 
          Contador = 5 
          Dados[0] = "B"
          Dados[1] = "O"
          Dados[2] = "T"
          Dados[3] = "Ã"
          Dados[4] = "O"
          goSUB Usb_Saida   
    
          GOTO Ler_Teclado
       endif
    GOTO Inicio
    
    '-------------------------------------------------------------------------------
    Usb_Saida:
       USBService
       USBOut 3, Dados, contador, Usb_Saida
    rETURN
    
    '-------------------------------------------------------------------------------
    Ler_Teclado:
       @ READKEYPAD _Botao
    
       Contador = 3
       Dados[0] = 96+Botao
       Dados[1] = 13
       Dados[2] = 10  
       goSUB Usb_Saida
    
    goto Ler_Teclado
    
    END

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    It never makes it to the keypad routine. Unless you send something from the PC.
    Then it only checks the keypad once.

    Code:
    Inicio:    <--------------------------------
       USBService                               |
                                                |
       contador = 1                             |
    	USBIn 3, Dados, contador, Inicio ---
    DT

  3. #3
    Join Date
    Sep 2006
    Location
    Venezuela - Caracas
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    i send 'B" from pc, print "BOTAO" and start keypad
    KEYPAD IN 16f628 IS OK...but in 18F4550 portb and portd not work

    Inicio:
    USBService

    contador = 1 'working
    USBIn 3, Dados, contador, Inicio 'working
    Toggle LED

    iF Dados[0]="B" tHEN 'working
    Contador = 5
    Dados[0] = "B"
    Dados[1] = "O"
    Dados[2] = "T"
    Dados[3] = "Ã"
    Dados[4] = "O"
    goSUB Usb_Saida

    GOTO Ler_Teclado
    endif
    GOTO Inicio

    '-------------------------------------------------------------------------------
    Usb_Saida: 'working
    USBService
    USBOut 3, Dados, contador, Usb_Saida
    rETURN

    '-------------------------------------------------------------------------------
    Ler_Teclado:
    Contador = 5 'working
    Dados[0] = "B"
    Dados[1] = "O"
    Dados[2] = "T"
    Dados[3] = "Ã"
    Dados[4] = "O"
    goSUB Usb_Saida

    @ READKEYPAD _Botao ' not working

    Contador = 3
    Dados[0] = 96+Botao
    Dados[1] = 13
    Dados[2] = 10
    goSUB Usb_Saida

    goto Ler_Teclado

    END
    Last edited by mpardinho; - 7th April 2007 at 21:58.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    It never makes it to the keypad routine. Unless you send something from the PC.
    Then it only checks the keypad once.

    Code:
    Inicio:    <--------------------------------
     | USBService                               |
     |                                          |
     | contador = 1                             |
      ----> USBIn 3, Dados, contador, Inicio ---
      ...
    
      ...
    
    @ READKEYPAD _Botao ' not working
    DT

Members who have read this thread : 1

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