Sie sind auf Seite 1von 7

ESCUELA POLITÉCNICA NACIONAL

DEPARTAMENTO DE AUTOMATIZACIÓN Y CONTROL


INDUSTRIAL

LABORATORIO DE:

SISTEMAS MICROPROESADOS

INFORME

Práctica:8 Tema: BARRIDO DE TECLADO

Realizado por: Jorge Fernando Benítez Solís

Grupo: Gr10

Fecha de entrega: 2019/01/08 f.


Recibido por:

Sanción:
LABORATORIO DE SISTEMAS MICROPROCESADOS
PRÁCTICA N°6
1. TEMA : BARRIDO DE TECLADO

2. DESARROLLO:
Diseñar un circuito, y el software asociado para manejar un teclado matricial de 16 teclas en conjunto con 4
display de 7 segmentos. Desarrollar programas en forma modular usando subrutinas.
Informe:

.def res=r0 out mcucr,tempo


.def resH=r1 ldi tempo,high(RAMEND)
.def cien=r5 out sph,tempo
.def diez=r6 ldi tempo,low(RAMEND)
.def tempo=r16 out spl,tempo
.def aux=r17 Inicio:
.def ante=r18 ldi tempo,0
.def tecla=r19 ldi seccion,0
.def cont=r20 sts NUM1,tempo
.def patron=r21 sts NUM2,tempo
.def seccion=r22 sts BINARIO,tempo
.dseg sts BINH,tempo
NUM1: .BYTE 1 sts Signo,tempo
NUM2: .BYTE 1 ldi tempo,100
OPERACION: .BYTE 1 mov cien,tempo
BINARIO: .BYTE 1 ldi tempo,10
BINH: .BYTE 1 mov diez,tempo
SIGNO: .BYTE 1 Barrido_Teclado:
bcd3: .BYTE 1 ldi ante,16
bcd2: .BYTE 1 ldi cont,3
bcd1: .BYTE 1 barrer:
bcd0: .BYTE 1 rcall bin_bcd_3
dig3: .BYTE 1 rcall bcd_7seg_4
dig2: .BYTE 1 rcall Barrido_4
dig1: .BYTE 1 ldi tecla,16
dig0: .BYTE 1 ldi tempo,0b11111110
.cseg out portc,tempo
.org 0x00 sbis pinc,4
ldi tempo,0b00001111 ldi tecla,25
out ddrc, tempo sbis pinc,5
ldi tempo,0b00000000 ldi tecla,2
out ddrd, tempo sbis pinc,6
ldi tempo,0b01111111 ldi tecla,3
out ddra, tempo sbis pinc,7
ldi tempo,0b00001111 ldi tecla,16
out ddrb, tempo ldi tempo,0b11111101
ldi tempo,0b11111111 out portc,tempo
out portc,tempo sbis pinc,4
out portd,tempo ldi tecla,1
ldi tempo,0b10000000 sbis pinc,5
out porta,tempo ldi tecla,5
ldi tempo,0b11111111 sbis pinc,6
out portb,tempo ldi tecla,6
in tempo, mcucr sbis pinc,7
andi tempo,0b11101111 ldi tecla,23
ldi tempo,0b11111011 sts Binario,tempo
out portc,tempo sts BinH,tempo
sbis pinc,4 ldi seccion,2
ldi tecla,4 ldi tempo,1
sbis pinc,5 ldi cont,3
ldi tecla,8 sts Operacion,tempo
sbis pinc,6 rjmp Finalizar
ldi tecla,9 Op_Resta:
sbis pinc,7 rcall Salto_Resta
ldi tecla,22 rjmp Finalizar
ldi tempo,0b11110111 Op_Multiplicacion:
out portc,tempo rcall Salto_Multiplicacion
sbis pinc,4 rjmp Finalizar
ldi tecla,7 Numero2:
sbis pinc,5 rcall Convertir2
ldi tecla,0 rjmp Finalizar
sbis pinc,6 Igual:
ldi tecla,20 cpi tecla,25
sbis pinc,7 breq Ingreso2
ldi tecla,21 cpi tecla,20
cp tecla,ante breq Resultado
breq barrer rjmp Finalizar
mov ante, tecla Ingreso2:
cpi tecla,16 ldi seccion,2
breq barrer ldi tempo,0
Secciones: ldi cont,3
cpi seccion,4 sts Binario,tempo
breq Completado sts BinH,tempo
cpi seccion,3 rjmp Finalizar
breq Igual Resultado:
cpi seccion,2 rcall Resolver
breq Numero2 rjmp Finalizar
cpi seccion,1 Completado:
breq Operation cpi tecla,25
cpi seccion,0 brne Finalizar
breq Numero1 ldi seccion,0
Numero1: ldi tempo,0
rcall Convertir1 ldi cont,3
rjmp Finalizar sts Binario,tempo
Operation: sts BinH,tempo
cpi tecla,25 sts Signo,tempo
breq Ingreso1 Finalizar:
cpi tecla,21 rjmp barrer
breq Op_Suma Salto_Multiplicacion:
cpi tecla,22 ldi tempo,0
breq Op_Resta sts Binario,tempo
cpi tecla,23 sts BinH,tempo
breq Op_Multiplicacion ldi seccion,2
rjmp Finalizar ldi tempo,3
Ingreso1: ldi cont,3
ldi seccion,0 sts Operacion,tempo
ldi tempo,0 ret
ldi cont,3 Salto_Resta:
sts Binario,tempo ldi tempo,0
sts BinH,tempo sts Binario,tempo
rjmp Finalizar sts BinH,tempo
Op_Suma: ldi seccion,2
ldi tempo,0 ldi tempo,2
ldi cont,3 ret
sts Operacion,tempo Decenas2:
ret dec cont
Convertir1: mul tecla,diez
cpi tecla,25 lds tempo,Binario
breq Limite1 add tempo,res
cpi cont,3 sts Binario,tempo
breq Centenas1 ret
cpi cont,2 Unidades2:
breq Decenas1 dec cont
cpi cont,1 lds tempo,Binario
breq Unidades1 add tempo,tecla
ret cpi tempo,128
Centenas1: brcc Limite2
cpi tecla,2 sts Num2,tempo
brcc Limite1 sts Binario,tempo
dec cont ldi seccion,3
mul tecla,cien ret
mov tempo,res Limite2:
sts Binario,tempo rcall reset
ret ret
Decenas1: Reset:
dec cont ldi cont,3
mul tecla,diez ldi tempo,0
lds tempo,Binario sts Binario,tempo
add tempo,res sts BinH,tempo
sts Binario,tempo ret
ret Resolver:
Unidades1: lds tempo,Num1
dec cont lds aux,Num2
lds tempo,Binario lds tecla,Operacion
add tempo,tecla cpi tecla,1
cpi tempo,128 breq Suma
brcc Limite1 cpi tecla,2
sts Num1,tempo breq Resta
sts Binario,tempo cpi tecla,3
ldi seccion,1 breq Multiplicacion
ret ret
Limite1: Suma:
rcall reset add tempo,aux
ret sts Binario,tempo
Convertir2: ldi seccion,4
cpi tecla,25 ldi tempo,0
breq Limite2 sts BinH,tempo
cpi cont,3 ret
breq Centenas2 Resta:
cpi cont,2 sub tempo,aux
breq Decenas2 brcs Negativo
cpi cont,1 sts Binario,tempo
breq Unidades2 ldi seccion,4
ret ldi tempo,0
Centenas2: sts BinH,tempo
cpi tecla,2 ret
brcc Limite2 Negativo:
dec cont neg tempo
mul tecla,cien sts Binario,tempo
mov tempo,res ldi tempo,1
sts Binario,tempo sts Signo,tempo
ldi seccion,4 ret
ldi tempo,0 bcd_7seg_4:
sts BinH,tempo push r16
ret in r16,sreg
Multiplicacion: push r16
mul tempo,aux push r17
mov tempo,res push xh
sts Binario,tempo push xl
mov tempo,resH push yh
sts BinH,tempo push yl
ldi seccion,4 push zh
ret push zl
bin_bcd_3: ldi xh,high(bcd3)
push r16 ldi xl,low(bcd3)
in r16,sreg ldi yh,high(dig3)
push r16 ldi yl,low(dig3)
push r17 ldi r17,4
push r18 lazo_bcd_7seg_4:
lds r16,Signo ldi zh,high(tabla_bcd_7seg<<1)
cpi r16,1 ldi zl,low(tabla_bcd_7seg<<1)
breq Negar ld r16,x+
ldi r16,17 add zl,r16
sts bcd3,r16 clr r16
rjmp Continuar adc zh,r16
Negar: lpm r16,z
ldi r16,16 st y+,r16
sts bcd3,r16 dec r17
Continuar: brne lazo_bcd_7seg_4
lds r16,binario pop zl
lds r18,binH pop zh
clr r17 pop yl
bin_bcd_3_centenas: pop yh
subi r16,low(100) pop xl
sbci r18,high(100) pop xh
brcs bin_bcd_3_decenas pop r17
inc r17 pop r16
rjmp bin_bcd_3_centenas out sreg,r16
bin_bcd_3_decenas: pop r16
sts bcd2,r17 ret
subi r16,low(-100) tabla_bcd_7seg:
sbci r18,high(-100) .db 0b10111111, 0b10000110, 0b11011011,
clr r17 0b11001111 ;0,1,2,3
bin_bcd_3_dec_1: .db 0b11100110, 0b11101101, 0b11111101,
subi r16,low(10) 0b10000111 ;4,5,6,7
sbci r18,high(10) .db 0b11111111, 0b11101111, 0b11110111,
brcs bin_bcd_3_unidades 0b11111100 ;8,9,A,B
inc r17 .db 0b10111001, 0b11011110, 0b11111001,
rjmp bin_bcd_3_dec_1 0b11110001 ;C,D,E,F
bin_bcd_3_unidades: .db 0b11000000, 0b10000000
sts bcd1,r17 Barrido_4:
subi r16,low(-10) push r16
sbci r18,high(-10) in r16,sreg
sts bcd0,r16 push r16
pop r18 push r17
pop r17 push r18
pop r16 push r19
out sreg,r16 push xh
pop r16 push xl
ldi xh,high(dig3) brne lazo_1_Barrido_4
ldi xl,low(dig3) ldi r16,0b11111111
ldi r17,4 out portb,r16
ldi r18,0b11110111 asr r18
ldi r16,0b11111111 dec r17
out portb,r16 brne lazo_0_Barrido_4
lazo_0_Barrido_4: pop xl
ld r16,x+ pop xh
ori r16,0b10000000 pop r19
out porta,r16 pop r18
out portb,r18 pop r17
ldi r19,255 pop r16
lazo_1_Barrido_4: out sreg, r16
dec r19 pop r16
nop ret
nop
nop
CONCLUSIONES
Se determino que se pudo realizar una calculadora capaz de realizar sumas restas y
multiplicaciones aplicando una subrutina a cada operación

Das könnte Ihnen auch gefallen