You are on page 1of 10

ESCUELA

POLITCNICA

NACIONAL
DEPARTAMENTO DE AUTOMATIZACIN Y CONTROL INDUSTRIAL

LABORATORIO DE SISTEMAS MICROPROCESADOS

informe
PRCTICA N: 9

TEMA: Interrupciones

REALIZADO POR: Octavio Beltrn Cristian Meja Grupo: Horario: Martes 14-16

Fecha de realizacin: 08 / 11 / 11
da mes ao

Fecha de entrega: 14/ 11 / 11


da mes ao

INFORME No. 9 LABORATORIO DE SISTEMAS MICROPROCESADOS INTERRUPCIONES

1. OBJETIVO: DISEAR UN CIRCUITO, Y EL SOFTWARE ASOCIADO PARA MANEJAR UN DISPOSITIVO QUE CONTROLA UN JUEGO DE 4 JUGADORES, EN CONJUNTO CON 4 DISPLAY DE 7 SEGMENTOS E INDICADORES Y SENSORES ADICIONALES. EL DISPLAY USAR LA TCNICA DE BARRIDO, Y SE TRABAJAR EXCLUSIVAMENTE CON INTERRUPCIONES EXTERNAS PARA MANEJO DE LOS SENSORES.
C1
0.1u

C2
0.1u 5

C3
0.1u

U1 C4
0.1u 40 41 42 43 44 1 2 3 9 10 11 12 13 14 15 16 29 27 4 PB0/XCK0/T0/PCINT8 PB1/T1/CLKO/PCINT9 PB2/AIN0/INT2/PCINT10 PB3/AIN1/OC0A/PCINT11 PB4/SS/OC0B/PCINT12 PB5/MOSI/PCINT13 PB6/MISO/PCINT14 PB7/SCK/PCINT15 PD0/RXD0/PCINT24 PD1/TXD0/PCINT25 PD2/INT0/RXD1/PCINT26 PD3/INT1/TXD1/PCINT27 PD4/OC1B/XCK1/PCINT28 PD5/OC1A/PCINT29 PD6/ICP/OC2B/PCINT30 PD7/OC2A/PCINT31 AREF AVCC RESET ATMEGA164P 0.1u PA0/ADC0/PCINT0 PA1/ADC1/PCINT1 PA2/ADC2/PCINT2 PA3/ADC3/PCINT3 PA4/ADC4/PCINT4 PA5/ADC5/PCINT5 PA6/ADC6/PCINT6 PA7/ADC7/PCINT7 PC0/SCL/PCINT16 PC1/SDA/PCINT17 PC2/TCK/PCINT18 PC3/TMS/PCINT19 PC4/TDO/PCINT20 PC5/TDI/PCINT21 PC6/TOSC1/PCINT22 PC7/TOSC2/PCINT23 XTAL1 XTAL2 37 36 35 34 33 32 31 30 19 20 21 22 23 24 25 26 8 7

R1
1k

R2
1k

R3
1k

R4
1k

R5
1k

Q4
2N3906

C5
0.1u

R6
1k

Q3
2N3906

R7
1k

Q2
2N3906

C6

R8
1k

Q1
2N3906

C7 0.1u

R9
330R

C8
1u

LS1

SPEAKER

.include "m164pdef.inc" .def tempo=r16 .def aux=r17 .def cont0=r18 .def cont1=r19 .def cont2=r20 .def cont3=r21 .def est_ant=r22 .def numero=r23

.org 0x00 jmp Reseteo .org 0x02 jmp inicio .org 0x04 jmp pausar .org 0x06 jmp apagar .org 0x000A jmp jugadores

Reseteo: ldi tempo,0b01111111 out DDRC,tempo ldi tempo,0b00001111 out DDRA,tempo ldi tempo,0b0000000 out DDRB,tempo ldi tempo,0b1000000 out DDRD,tempo ldi tempo,0b11111111 out portb,tempo out porta,tempo ldi tempo,0b01111111 out portd,tempo ldi tempo,0b10000000 out portc,tempo

in tempo,MCUCR andi tempo,0b11101111 out MCUCR,tempo ldi tempo,high (ramend) out sph,tempo ldi tempo,low(ramend) out spl,tempo clr cont0 clr cont1 clr cont2 clr cont3 ldi tempo,0b00101010 ;determino si es subida o bajada sts EICRA,tempo ldi tempo,0b00000111 out EIMSK,tempo ldi tempo,0b11110000 sts PCMSK1,tempo ldi tempo,0b00000010 sts PCICR,tempo ldi tempo,0b00001111 out PCIFR,tempo SEI lazo: out porta,tempo rjmp lazo INICIO: push tempo ;Ninguna interrupcion pendiente ;Para habilitar el SREG ;hablitacion global ;hablitacion PB4....PB7

in tempo,SREG push tempo Jugadores: in aux,pinb sbrc aux,4 call jugador0 sbrc aux,5 call jugador1 sbrc aux,6 call jugador2 sbrc aux,7 call jugador3 rjmp salir Jugador3: sbis pinb,0 ret inc cont3 cpi cont3,9 breq tres ret tres: clr cont3 ldi tempo,0b10000000 out portd,tempo call retardo ret Jugador2: ; pruebo un pin directamente esta en 1

sbis pinb,0 ret inc cont2 cpi cont2,9 breq Dos ret Dos: clr cont2

; pruebo un pin directamente esta en 1

ldi tempo,0b10000000 out portd,tempo call retardo ret Jugador1: sbis pinb,0 ret inc cont1 cpi cont1,9 breq Uno ret Uno: clr cont1 ldi tempo,0b10000000 out portd,tempo call retardo ret Jugador0: sbis pinb,0 ; pruebo un pin directamente esta en 1 ; pruebo un pin directamente esta en 1

ret inc cont0 ldi numero,0b00000010 out porta,numero mov tempo,cont0 out portc,tempo cpi cont0,9 breq Cero ret cero: clr cont0 ldi tempo,0b10000000 out portd,tempo ldi numero,0b10000010 out portc,numero call retardo ret Salir: pop tempo out SREG,tempo pop tempo reti PAUSAR: push tempo in tempo,SREG push tempo APAGAR:

push tempo in tempo,SREG push tempo ldi tempo,0b01111111 out portd,tempo rjmp lazo pop tempo out SREG,tempo pop tempo RET retardo:

ldi cont0,196 retardo1: retardo2: retardo3: ldi cont1,9 ldi cont2,69 dec cont2 nop brne retardo3 dec cont1 brne retardo2 dec cont0 nop brne retardo1 reti TABLA: .DB 0b01000000, 0b01111001 ; CDIGOS 0 y 1 .DB 0b00100100, 0b00110000 ; CDIGOS 2 y 3

.DB 0b00011001, 0b00010010 ; CDIGOS 4 y 5 .DB 0b00000010, 0b01111000 ; CDIGOS 6 y 7 .DB 0b00000000, 0b00010000 ; CDIGOS 8 y 9
Comentario: Con esta prctica podemos observar la utilidad de las interrupciones las que no permiten ampliar an ms las aplicaciones de los microcontroladores especialmente en el campo de la automatizacin de procesos . Por consiguiente para esta practica hemos utilizado el microcontrolador atpmega164p como contador, sumador y decodificador, generador de seales lo que claramente nos permite ahorrar espacio en el montaje del circuito especialmente cuando se trata de circuitos muchos ms complejos donde el espacio que se ocupa se vuelve fundamental. Octavio Beltrn

Se concluye que la practica realzada amplio el estudio del manejo de interrupciones de las principales y de las alternas de una forma didctica por medio del juego.

Se concluye que hay que identificar cada habilitacin, cada registro para poder utilizar de buena manera cada pata del micro.

Se recomienda analizar correctamente cada puerto, identificar si es salida o entrada y adems habilitar los pull up.

Se recomienda conectar correctamente la sirena, verificando la salida para conectarle hacia el micro.

Cristian Meja

Aumentamos los conocimientos acerca del manejo de interrupciones, los cuales permiten obtener pulsos los cuales nos habilitan la instruccin que le demos.

Diseamos e implementamos el juego de bsquet con lo cul utilizamos todos los diferentes recursos de las interrupciones, con la ayuda del manual se puedo programar correctamente.

Es necesario utilizar los anti rebotes por software o por hardware, para que en cada pulso no se vayan cambiando los valores.

Bibliografia:

Materia dictado pro el Ing. Chico, Tema Interrupciones

You might also like