Professional Documents
Culture Documents
FACULTAD DE INGENIERAS INGENIERA ELECTRNICA Sistemas micro procesados INFORME DE LABORATORIO Practica 7 Interrupciones Nombres: ANGEL ACHIG CRISTIAN GUALOTUA CRISTBAL VILLAGOMEZ
QUITO ECUADOR
2011
DATASHEETS
LCD 2X16
DESARROLLO PRCTICO
OBJETIVO: Elaborar programas para comprender el uso de las interrupciones. 1. EJERCICIO 1 PROBLEMA: Uso de la interrupcin externa cero CDIGO
program INT0 dim L as byte dim A,B as byte dim valor as string[6] sub procedure init trisc=$0 trisd=$0 trisb=$FF 'puertob como entradas option_reg=%10000000 'habilita todas las interrupciones por flanco descendente 'prescaler no habilitado intcon=%10010000 'habilita interrupciones e interrupcion externa RB0 L=0 A=0 B=0 Lcd_config(portc,7,6,5,4, portc,0,1,2) 'configuro LCD lcd_cmd(lcd_cursor_off) end sub sub procedure interrupt portd=inc(B) intcon.intF=0 A=A+1 end sub main: init LOOP: byteTOSTR(A,valor) lcd_cmd(lcd_clear) lcd_out(1,1,valor) delay_ms(500) goto LOOP end.
Simulacin en proteus
Imagen de la practica
Diagrama en proteus
Muestra en el osciloscopio
En el osciloscopio
3. EJERCICIO 3 PROBLEMA: Mediante el uso de la interrupcin del timer 1 realizar un generador de onda cuadrada de periodo 1ms..
CDIGO program Timer1 dim cnt as word dim B as byte sub procedure interrupt Inc(cnt) PIR1.TMR1IF = 0 ' clear TMR1IF TMR1H = $FF TMR1L = $00 end sub main: PORTB = $00 ' initialize PORTB TRISB = 0 ' PORTB is output T1CON = 1 ' timer1 settings PIR1.TMR1IF = 0 ' clear TMR1IF TMR1H = $80 ' initialize Timer1 register TMR1L = $00 PIE1.TMR1IE = 1 ' enable Timer1 interrupt cnt = 0 ' initialize cnt INTCON = $C0 ' set GIE, PEIE while TRUE if (cnt = 3) then ' if cnt is 76 PORTB = inc(B) ' then toggle PORTB leds and cnt = 0 ' reset cnt end if wend end.
Simulacin en el proteus
Imagen en el proto
Imagen en el osciloscopio
program medidor dim L as byte dim A,B as byte dim valor as string[6] sub procedure init trisc=$0 trisd=$0 trisb=$FF option_reg=%10000011
intcon=%10010000 L=0 A=0 B=0 lcd_config(portc,7,6,5,4,portc,0,1,2) lcd_cmd(lcd_cursor_off) end sub sub procedure interrupt portd=inc(B) intcon.intF=0 if L=0 then tmr0=0 L=1 else L=0 A=tmr0 end if end sub main: init LOOP: byteTOSTR(A,valor) lcd_cmd(lcd_clear) lcd_out(1,1,valor) delay_ms(500) goto LOOP end.
EJERCICIO 5 PROBLEMA: Que cambios debe realizar para observar la frecuencia en el LCD.. CDIGO
program interrupcion5 dim L as byte dim a,b as byte dim fre as word dim valor as string[6] sub procudere init trisc=0 trisd=0 trisb=$FF option_reg=%10000111 intcon=%10010000 L=0 a=0 b=0 lcd_config(portc,7,6,5,4,portc,0,1,2) lcd_cmd(lcd_cursor_off) end sub sub procedure interrupt portd=inc(b) INTCON.INTF=0 if L=0 then TMR0=0 L=1 else L=0 a=TMR0 fre=(1000/a*19) end if end sub main: init LOOP: wordtostr(fre,valor) lcd_cmd(lcd_clear) lcd_out(1,1,valor) delay_ms(500) goto LOOP end.
Imagen en el proto
Frecuencia mostrada
CONCLUSIONES La operacin de lectura o de adquisicin de datos no representa ningn tipo de problema; solamente se deber cambiar el orden de los operando en la instruccin respecto a la de interrupciones.
Que la elaboracin nos sirve para comprender un poco ms la teora de los microcontroladores y su aplicacin; de ah la importancia del mismo, pues a travs de l se puede apreciar lo interesante de la construccin de los microcontroladores y utilizamos las interrupciones del microcontrolador en la programacin. Como los puertos estn asignados a un espacio separado de la memoria, se tiene disponible la capacidad total de direccionamiento del microprocesador para circuitos de memoria y tiempos. BIBLIOGRAFIA http://ww1.microchip.com/downloads/en/devicedoc/39582b.pdf. datasheet. micro controlador 16f877A fecha de revisin: 06/12/2011
Hojas guas de la prctica. Proporcionadas por el Ing. Luis Oate