Autor Tema: problemas con teclado y 16F628A  (Leído 1556 veces)

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

Desconectado dagger

  • PIC12
  • **
  • Mensajes: 68
problemas con teclado y 16F628A
« en: 11 de Octubre de 2010, 16:35:46 »
Hace un tiempito un amigo me  ayudo a realizar este proyecto con un 16F628A.
En realidad nunca se probo..se simulo en proteus...
Consta de un teclado de 4x3 que se conecta a 2 CD4043 y de alli a 2 CD4511 y 2 displays.
Se debe escribir como una calculadora y que se muestre la cifra de 2 digitos.
Luego con la tecla numeral se borra.
la cuestion es que se probo en proteus pero al construirlo...non funca.... :5] :5]
Bueno este amigo ya no esta disponible y necesitaria a ver si me pueden ayudar...si ven algun error.... :oops: :oops:
Tal vez faltan los seteos...??? osc. interno..sin wdog..sin LVP..????
Desde ya muchas gacias

; Proyecto de teclado y display
; El código de unidad es DCBA, puertos RA3...RA0 respectivamente
; El código de decena es CBA, puertos RA7, RA6 y RA4
; respectivamente. Como consecuencia de esto la decena puede tomar
; el valor 7 como máximo

; El puerto RB0, se hace 1 cuando se presiona la tecla #,
; de este modo se borran los display


   #include   <p16f628a.inc>

DelayA      equ      20h
DelayB      equ      21h
KeyCounter   equ      22h
Unidad      equ      23h
Decena      equ      24h
Key         equ      25h
Tmp         equ      26h


   org      00h
   goto   Inicio
   org      04h
   goto   Interrupt

KeyDelay
   movlw   .20
   movwf   DelayA
KeyDelayA
   movlw   .100
   movwf   DelayB
KeyDelayB
   decfsz   DelayB,F
   goto   KeyDelayB
   decfsz   DelayA,F
   goto   KeyDelayA
   return

Tabla
   addwf   PCL,F
   retlw   .1
   retlw   .4
   retlw   .7
   retlw   .255
   retlw   .2
   retlw   .5
   retlw   .8
   retlw   .0
   retlw   .3
   retlw   .6
   retlw   .9
   retlw   .10
   

DecoKey
   clrf   Key
   movlw   b'11111100'
   iorwf   PORTB,F
Ciclo
   btfss   PORTB,4
   goto   LeerTabla
   incf   Key,F
   btfss   PORTB,5
   goto   LeerTabla
   incf   Key,F
   btfss   PORTB,6
   goto   LeerTabla
   incf   Key,F
   btfss   PORTB,7
   goto   LeerTabla
   incf   Key,F
   movlw   .12
   subwf   Key,W
   btfsc   STATUS,Z
   goto   FinTabla
   movf   PORTB,W
   movwf   Tmp
   rrf      Tmp,W
   bsf      Tmp,0
   rlf      Tmp,F
   movf   Tmp,W
   movwf   PORTB
   goto   Ciclo
LeerTabla
   movf   Key,W
   call   Tabla
   movwf   Key
   return
FinTabla
   movlw   .255
   movwf   Key
   return

Interrupt
   bcf      INTCON,GIE
   call   KeyDelay
   call   DecoKey

   movlw   .10
   subwf   Key,W
   btfsc   STATUS,Z
   goto   Numeral   
   btfsc   STATUS,C
   goto   EndInterrupt   ; si es mayor a #, no hago nada
   goto   NoNumeral

Numeral
   bcf      KeyCounter,0
   clrf   Decena
   clrf   Unidad
   bsf      PORTB,0
   goto   Algo

NoNumeral
   btfss   KeyCounter,0
   goto   EscribeUnidad
   movf   Unidad,W
   movwf   Decena

EscribeUnidad
   bsf      KeyCounter,0
   movf   Key,W
   movwf   Unidad

Algo
   clrf   Tmp
   bcf      STATUS,C
   rrf      Decena,F
   rrf      Tmp,F
   rrf      Tmp,F
   rrf      Decena,F
   rrf      Tmp,F
   rrf      Decena,F
   rrf      Tmp,F
   movf   Unidad,W
   iorwf   Tmp,W
   movwf   PORTA
   call   KeyDelay
   bcf      PORTB,0

EndInterrupt
   movlw   b'11110001'
   andwf   PORTB,F
   bcf      INTCON,RBIF
   retfie

Inicio
   movlw   b'11001111'
   movwf   CMCON
   bsf      STATUS,RP0
   clrf   TRISA
   movlw   b'11110000'
   movwf   TRISB
   bcf      STATUS,RP0
   clrf   PORTA
   clrf   PORTB
   movlw   b'01011111'
   movwf   OPTION_REG
   movlw   b'10001000'
   movwf   INTCON
   clrf   KeyCounter
   clrf   Unidad
   clrf   Decena

LoopPrincipal

   nop
   nop
   nop
   goto   LoopPrincipal
   end

teclado

Así es como conecté el teclado al PIC. En RB4 a RB7 usé las
resistencias de pull-up internas del PIC.




    Rb1    Rb2    Rb3
     |     |     |
     |     |     |
   ┌───┐   ┌───┐   ┌───┐
Rb4 ----│ 1 │---│ 2 │---│ 3 │ fila 1
   └───┘   └───┘   └───┘
     |     |     |
   ┌───┐   ┌───┐   ┌───┐
Rb5 ----│ 4 │---│ 5 │---│ 6 │ fila 2
   └───┘   └───┘   └───┘
     |     |     |
   ┌───┐   ┌───┐   ┌───┐
Rb6 ----│ 7 │---│ 8 │---│ 9 │ fila 3
   └───┘   └───┘   └───┘
     |     |     |
   ┌───┐   ┌───┐   ┌───┐
Rb7 ----│ * │---│ 0 │---│ # │ fila 4
   └───┘   └───┘   └───┘
      
        col 1   col 2   col 3
« Última modificación: 12 de Octubre de 2010, 15:09:13 por dagger »

Desconectado dagger

  • PIC12
  • **
  • Mensajes: 68
Re: problemas con teclado y 16F628A
« Respuesta #1 en: 18 de Octubre de 2010, 09:22:45 »
a nadie se le ocurre nada...???? :? :? :?