Autor Tema: Ayuda Teclado Matricial 4x4 PIC18F4550 Conexión  (Leído 7419 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado BlackWolf90

  • PIC10
  • *
  • Mensajes: 1
Ayuda Teclado Matricial 4x4 PIC18F4550 Conexión
« en: 06 de Noviembre de 2013, 08:41:38 »
Hola a todos:

Soy nuevo en el foro y es la primera vez que pido ayuda, espero que me puedan ayudar, bueno aquí la cosa es que estoy realizando una práctica con un teclado matricial 4x4 con un PIC 18F4550, y para este caso pues la codificación es un poco ummm basíca (?) a diferencia del código similar a C++ que he visto que usan mucho aquí, y aunque el problema no es mi programa sino la conexión del teclado al pic, me comentaba mi profesor, que el teclado, enviaba estados bajos (ceros) al PIC al momento de ser presionada una tecla, y que al estar sin oprimir recibía estados altos (unos), esto haciendo uso de las resistencias internas del PIC a través del puerto. El problema es que en el teclado quedan todas las teclas en estados altos y aún presionandolas pues no sirve de nada... dejo el diseño en PROTEUS de como esta la configuración (A pesar de ser simulado, el teclado matricial físico que tengo es similar al de la simulación, dando el mismo resultado.)

El programa está diseñado para que al momento de presionar una tecla se muestre el dígito o letra correspondiente en letras Azules... mientras que al no presionar ninguna tecla en el display se mostrará la letra "H". Quizá sea nuevo en conectar éste tipo de dispositivos como es el teclado, así que por eso pido su ayuda... dejo el código del programa si de algo sirve. En las imagenes del simulador presiono la tecla 5 como ejemplo.

Espero su pronta respuesta, gracias y saludos.









------------------------------------------------------------------------Código------------------------------------------------------------------------
;******************************************************************************
;   This file is a basic template for assembly code for a PIC18F4550. Copy    *
;   this file into your project directory and modify or add to it as needed.  *
;                                                                             *
;   The PIC18FXXXX architecture allows two interrupt configurations. This     *
;   template code is written for priority interrupt levels and the IPEN bit   *
;   in the RCON register must be set to enable priority levels. If IPEN is    *
;   left in its default zero state, only the interrupt vector at 0x008 will   *
;   be used and the WREG_TEMP, BSR_TEMP and STATUS_TEMP variables will not    *
;   be needed.                                                                *
;                                                                             *
;   Refer to the MPASM User's Guide for additional information on the         *
;   features of the assembler.                                                *
;                                                                             *
;   Refer to the PIC18FXX50/XX55 Data Sheet for additional                    *
;   information on the architecture and instruction set.                      *
;                                                                             *
;******************************************************************************
;                                                                             *
;    Filename:    PlantillaASM                                                *
;    Date:        12/01/11                                                    *
;    File Version: 1.0                                                        *
;                                                                             *
;    Author:   Ing. Alejandro Vicente Lugo Silva                              *
;    Company:   Acad. Computación ICE - ESIME Zac.                            *
;                                                                             *
;******************************************************************************
;                                                                             *
;    Files required: P18F4550.INC                                             *
;                                                                             *
;******************************************************************************

   LIST P=18F4550, F=INHX32   ;directive to define processor
   #include <P18F4550.INC>      ;processor specific variable definitions

;******************************************************************************
;Configuration bits

   CONFIG PLLDIV   = 5         ;(20 MHz crystal on PICDEM FS USB board)
    CONFIG CPUDIV   = OSC1_PLL2   
    CONFIG USBDIV   = 2         ;Clock source from 96MHz PLL/2
    CONFIG FOSC     = HSPLL_HS
    CONFIG FCMEN    = OFF
    CONFIG IESO     = OFF
    CONFIG PWRT     = OFF
    CONFIG BOR      = ON
    CONFIG BORV     = 3
    CONFIG VREGEN   = ON      ;USB Voltage Regulator
    config WDT      = OFF
    config WDTPS    = 32768
    config MCLRE    = ON
    config LPT1OSC  = OFF
    config PBADEN   = OFF      ;NOTE: modifying this value here won't have an effect
                               ;on the application.  See the top of the main() function.
                               ;By default the RB4 I/O pin is used to detect if the
                               ;firmware should enter the bootloader or the main application
                               ;firmware after a reset.  In order to do this, it needs to
                               ;configure RB4 as a digital input, thereby changing it from
                               ;the reset value according to this configuration bit.
    config CCP2MX   = ON
    config STVREN   = ON
    config LVP      = OFF
    config ICPRT    = OFF       ; Dedicated In-Circuit Debug/Programming
    config XINST    = OFF       ; Extended Instruction Set
    config CP0      = OFF
    config CP1      = OFF
    config CP2      = OFF
    config CP3      = OFF
    config CPB      = OFF
    config CPD      = OFF
    config WRT0     = OFF
    config WRT1     = OFF
    config WRT2     = OFF
    config WRT3     = OFF
    config WRTB     = OFF       ; Boot Block Write Protection
    config WRTC     = OFF
    config WRTD     = OFF
    config EBTR0    = OFF
    config EBTR1    = OFF
    config EBTR2    = OFF
    config EBTR3    = OFF
    config EBTRB    = OFF
;******************************************************************************
;Variable definitions
; These variables are only needed if low priority interrupts are used.
; More variables may be needed to store other special function registers used
; in the interrupt routines.
   CBLOCK
      DatoNO
      Dato0
      Dato1
      Dato2
      Dato3
      Dato4
      Dato5
      Dato6
      Dato7
      Dato8
      Dato9
      DatoA
      DatoB
      DatoC
      DatoD
      DatoE
      DatoF
   ENDC

;******************************************************************************
;Reset vector
; This code will start executing when a reset occurs.

RESET_VECTOR   ORG      0

      goto   Main      ;go to start of main code

;******************************************************************************

;******************************************************************************
;Start of main program
; The main program code is placed here.
   ORG      0x1000
Main             ; *** main code goes here **
   movlw   0xFF   ;Tecla No Oprimida
   movwf   DatoNO
   movlw   0x77   ;Cero
   movwf   Dato0
   movlw   0x7B   ;Uno
   movwf   Dato1
   movlw   0x7D   ;Dos
   movwf   Dato2
   movlw   0x7E   ;Tres
   movwf   Dato3
   movlw   0xB7   ;Cuatro
   movwf   Dato4
   movlw   0xBB   ;Cinco
   movwf   Dato5
   movlw   0xBD   ;Seis
   movwf   Dato6
   movlw   0xBE   ;Siete   
   movwf   Dato7
   movlw   0xD7   ;Ocho
   movwf   Dato8   
   movlw   0xDB   ;Nueve
   movwf   Dato9
   movlw   0xDD   ;Diez(A)
   movwf   DatoA
   movlw   0xDE   ;Once(B)
   movwf   DatoB
   movlw   0xE7   ;Doce(C)
   movwf   DatoC
   movlw   0xEB   ;Trece(D)
   movwf   DatoD
   movlw   0xED   ;Catorce(E)
   movwf   DatoE
   movlw   0xEE   ;Quince(F)
   movwf   DatoF
   
   call   ConfigPtos
Rep   
   call   Inicio
   clrf   PORTB
   goto   Rep


               ; end of main   
;******************************************************************************
; Start of subrutines
;******************************************************************************
ConfigPtos
      movlw   0x0F
      movwf   ADCON1
      movlw   0x07
      movwf   CMCON
      movlw   0x00
      movwf   TRISD
      movlw   0xFF
      movwf   TRISB
      bcf      INTCON2,7
      return
      
;------------------------------------- Teclas -----------------------------------------   
Inicio
      movf   PORTB,W
      cpfseq   DatoNO,W
      goto   Sigue
      call   ACHE
      return
Sigue      
      cpfseq   Dato0,W
      goto   Sigue1
      call   CERO
      return
Sigue1
      cpfseq   Dato1,W
      goto   Sigue2
      call   UNO
      return
Sigue2
      cpfseq   Dato2,W
      goto   Sigue3
      call   DOS
      return
Sigue3
      cpfseq   Dato3,W
      goto   Sigue4
      call   TRES
      return
Sigue4
      cpfseq   Dato4,W
      goto   Sigue5
      call   CUATRO
      return
Sigue5
      cpfseq   Dato5,W
      goto   Sigue6
      call   CINCO
      return
Sigue6      
      cpfseq   Dato6,W
      goto   Sigue7
      call   SEIS
      return
Sigue7
      cpfseq   Dato7,W
      goto   Sigue8
      call   SIETE
      return
Sigue8
      cpfseq   Dato8,W
      goto   Sigue9
      call   OCHO
      return
Sigue9
      cpfseq   Dato9,W
      goto   SigueA
      call   NUEVE
      return
SigueA
      cpfseq   DatoA,W
      goto   SigueB
      call   DIEZ
      return
SigueB
      cpfseq   DatoB,W
      goto   SigueC
      call   ONCE
      return
SigueC
      cpfseq   DatoC,W
      goto   SigueD
      call   DOCE
      return
SigueD
      cpfseq   DatoD,W
      goto   SigueE
      call   TRECE
      return
SigueE
      cpfseq   DatoE,W
      goto   SigueF
      call   CATORCE
      return
SigueF
      cpfseq   DatoF,W
      call   QUINCE
      goto   Inicio
      return
;-------------------------------------------------------------------------------------
;--------------------------------- Letras/Numeros-------------------------------------
ACHE
      movlw   0x76
      movwf   LATD
      return
CERO
      movlw   0x3F
      movwf   LATD
      return
UNO
      movlw   0X06
      movwf   LATD
      return
DOS
      movlw   0X5B
      movwf   LATD
      return
TRES
      movlw   0X4F
      movwf   LATD
      return
CUATRO
      movlw   0X66
      movwf   LATD
      return
CINCO
      movlw   0X6D
      movwf   LATD
      return
SEIS
      movlw   0X7D
      movwf   LATD
      return
SIETE
      movlw   0X07
      movwf   LATD
      return
OCHO
      movlw   0X7F
      movwf   LATD
      return
NUEVE
      movlw   0X6F
      movwf   LATD
      return
DIEZ
      movlw   0X77
      movwf   LATD
      return
ONCE
      movlw   0X7C
      movwf   LATD
      return
DOCE
      movlw   0X39
      movwf   LATD
      return
TRECE
      movlw   0X5E
      movwf   LATD
      return
CATORCE
      movlw   0X79
      movwf   LATD
      return
QUINCE
      movlw   0X71
      movwf   LATD
      return
;-------------------------------------------------------------------------------------
;******************************************************************************
;End of program
   END





 

anything