ejercicos en atmega 164p teclado matricial con interrupciones
-
Upload
wilmer-villegas-codena -
Category
Documents
-
view
1.494 -
download
1
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