ejercicos en atmega 164p teclado matricial con interrupciones

6
ESCUELA POLITECNICA NACIONAL SISTEMAS MICROPROCESADOS NOMBRES: Wilmer Villegas FECHA: 20 04 2012 Realizar un programa para visualizar en un display la tecla presionada de un teclado matricial para este caso vamos a usar el método de barrido de teclado con interrupciones. PROGRAMA EN AVR: .include"m164pdef.inc" ;declaro las variables que voy a usar .def tempo=r17 .def tecla=r18 .def aux=r19 .def conta1=r20 .def conta2=r21 .def conta3=r22 ;pongo los vectores de interrupciones .org 0x00 jmp main .org 0x02 jmp teclado main: ;configuro como salidas ser tempo out ddrb,tempo ;configuro como entradas y s a l i d a s para poder usar mi teclado ldi tempo,0b00001111 out ddra,tempo ;configuro pull-up y s a l i d a s normalmente en 1L ldi tempo,0b11111111 out porta,tempo ;configuro como entradas l a s i n t e r r u p c i o n e s clr tempo out ddrd,tempo ldi tempo,0b00000100 out portd,tempo ;garantizo pull-up in tempo,mcucr andi tempo,0b11101111 out mcucr,tempo ;inicializo el SP ldi r16,high(ramend) out sph,r16 ldi r16,low(ramend) out spl,r16 ;habilitacion individual de l a s i n t e r r u p c i o n e s ldi tempo,0b00000001 out eimsk,tempo ;pongo como quiero que s e desencadene mi interrupcion ldi tempo,0b00000010 sts eicra,tempo ;habilitación global de interrupciones s e i clr aux ldi tecla,16 l a z o : ldi tempo,0b11110000 out porta,tempo mov aux,tecla call visualizar rjmp lazo

Transcript of ejercicos en atmega 164p teclado matricial con interrupciones

ESCUELA POLITECNICA NACIO NAL SISTEMAS MICROPROCESADOS NOMBRES: Wil mer Villegas FECHA: 20 04 2012 Realizar un program a para visualizar en un display la tecla presionada de un teclado matricial para este caso vamos a usar el mtodo de barrido de teclado con interrupciones. PROGRAMA EN AVR: .include" m164pdef.inc" ;declaro las variables que voy a usar .def tempo=r17 .def tecla=r18 .def aux=r19 .def conta1=r20 .def conta2=r21 .def conta3=r22 ;pongo los vectores de interrupciones .org 0x00 j mp main .org 0x02 j mp teclado

main: ;configuro como salidas ser tempo out ddrb,tempo ;configuro como entr adas y salidas para poder usar mi teclado ldi tempo,0b00001111 out ddra,tempo ;configuro pull -up y salidas nor mal mente en 1L ldi tempo,0b11111111 out porta,tempo ;configuro como entradas las interrupciones clr tempo out ddrd,tempo

ldi tempo,0b00000100 out portd,tempo ;garanti zo pull -up in tempo,mcucr andi tempo,0b11101111 out mcucr,tempo ;inicializo el SP ldi r16,hi gh(ramend) out sph,r16 ldi r16,low(ramend) out spl,r16 ;habilitacion indivi dual de interrupciones ldi tempo,0b00000001 out ei msk,tempo ;pongo como qui ero que desencadene mi interrupcion ldi tempo,0b00000010 sts eicra,tempo

las

se

;habilitacin global de interrupciones sei clr aux ldi tecla,16 lazo: ldi tempo,0b11110000 out porta,tempo mov aux,tecla call visuali zar rj mp lazo

visuali zar: cpi tecla,16 breq off ldi zh,hi gh(TABLA