Teclado Matricial Para 80C51 En Ensamblador

Páginas: 5 (1158 palabras) Publicado: 1 de mayo de 2012
A) Teclado matricial con displays multiplexados

$include(reg51.inc)

code at 0
sjmp INI
INI: ;mov P1,#0FFh
mov SP,#2Fh
mov R0,#00h
mov R1,#0FEh
mov R4,#077h
next: mov P3,R1
mov A,P3
orl A,#00Fh
cjne A,#0FFh,rebot
mov A,R1
setb C
rlc A
mov R1,A
inc R0
mov A,R0
cjne A,#04h,next
jmp INI

rebot: mov R2,A ;Subrutina de rebote de
espera:mov A,P3 ;de software
orl A,#0Fh
cjne A,#0FFh,espera

cont: mov A,R2
mov R3,#00h ;columna
next2: rlc A
jnc tecla
inc R3
jmp next2

tecla: mov A,R0 ;rastrea la tecla oprimida
clr C
rlc A
rlc A
add A,R3
mov DPTR,#100h ;el valor de la tecla para
movc A,@A+DPTR ;ser usado en el display
cjne A,#71h,N1
one: mov P1,#9Fh
setB P2.0call delay
mov P1,#48h
setB P2.1
call delay
clr P2.1
djnz R4,one
jmp INI
N1: cjne A,#60h,N2
two: mov P1,#9Fh
setB P2.0
call delay
clr P2.0
mov P1,#98h
setB P2.1
call delay
clr P2.1
djnz R4,two
jmp INI
N2: cjne A,#84h,N3
tree: mov P1,#9Fh
setB P2.0
call delay
clr P2.0
mov P1,#0Ch
setB P2.1
call delayclr P2.1
djnz R4,tree
jmp INI
N3: cjne A,#62h,N4
fourth:mov P1,#9Fh
setB P2.0
call delay
clr P2.0
mov P1,#24h
setB P2.1
call delay
clr P2.1
djnz R4,fourth
jmp INI
N4: cjne A,#0C0h,N5
five: mov P1,#9Fh
setB P2.0
call delay
clr P2.0
mov P1,#9Fh
setB P2.1
call delay
clr P2.1
djnz R4,five
jmp INI
N5: cjneA,#10h,sigue
six: mov P1,#9Fh
setB P2.0
call delay
clr P2.0
mov P1,#02h
setB P2.1
call delay
clr P2.1
djnz R4,six
jmp INI
sigue: clr P2.0
mov P1,A
setB P2.1
call delay2
clr P2.1 ;salida a traves del puerto1
jmp INI


code at 100h
ASCII: DB 71h,60h,84h,62h,0C0h,10h,18h,00h,1Fh,40h,48h,98h,0Ch,24h,9Fh,02h

code at 190hdelay: mov R5,#07h
comon1: mov R6,#088h
comon: NOP
djnz R6,comon
djnz R5,comon1
clr P2.0
ret

delay2: mov R5,#0F2h
comon3: mov R6,#0FFh
comon2: NOP
djnz R6,comon2
djnz R5,comon3
clr P2.0
ret

end




























































[pic]
Fig.1. Resultado de lasimulación para el teclado matricial y displays multiplexados presionando la tecla 15.* los resultados en el display pueden no ser mostrados por la calidad de las impresiones pero se cuenta con la simulación

Como se puede ver en la figura hay un problemita con el manejo del software PROTEUS pues no trabaja muy bien a frecuencias mayores a 4 MHz por lo que no se aprecia la frecuencia de 33.3ms paraser apreciado por el ojo humano.

[pic]
Fig.2. simulación al presionar la tecla 6
El control de activación de los displays se hizo atravez de los bit 0 y 1 del puerto 2.
B) Aplicación para la matriz de puntos

$INCLUDE (REG51.INC)

HEAD DATA P1
LBUFF DATA 100H
CR EQU 0DH

ORG 00H
MOV R0,#40H
MOV A,#'H'
MOV @R0,A
INC R0
MOV A,#'O'
MOV @R0,A
INC R0
MOVA,#'L'
MOV @R0,A
INC R0
MOV A,#'A'
MOV @R0,A
INC R0
MOV A,#0DH
MOV @R0,A
CALL PRLINE
SJMP $

PRLINE: PUSH ACC
PUSH PSW
MOV R0,#40H
LOOP1: MOV A,@R0
CJNE A,#CR,CONT
SJMP DONE
CONT: CALL LOOKUP
MOV R2,#5
MOV B,#00

LOOP2: MOV A,B
MOVC A,@A+DPTR
MOV HEAD, A
CALL STEP2
INC B
DJNZ R2,LOOP2
CALL STEP
CALL STEP
INC R0
JMPLOOP1
DONE: POP PSW
POP ACC
RET

LOOKUP: MOV DPTR,#LBUFF
MOV R1,A
MOV A,#90
SUBB A,R0
JC BRINCONO
MOV A,R1
SUBB A,#65
JC BRINCONO
MOV A,R1
SUBB A,#41H
MOV R3,A
CLR C
RLC A
RLC A
ADD A,R3
ADD A,DPL
MOV DPL,A
BRINCONO: RET

STEP: MOV R6,#04H
MOV P1,#00H
OTRA: NOP
NOP
DJNZ R6,OTRA
RET

STEP2: MOV R6,#04H
NOP
OTRA2:NOP...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Teclado Matricial
  • Teclado matricial
  • Teclado matricial
  • Teclado Matricial
  • Teclado Matricial
  • Teclados matriciales
  • Teoria teclado matricial
  • Teclado Matricial Assembler

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS