lab2
TRANSCRIPT
![Page 1: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/1.jpg)
UNIVERSIDAD NACIONAL DE INGENIERÍA
FACULTAD DE INGENIERÍA MECÁNICA
INFORME DE LABORATORIO N°2
CURSO: SISTEMAS EMBEBIDOS (MT136 A)
GRUPO N°: 2
ALUMNOS:
Calderón Oscanoa, Ronny 20122516F
Farceque Cruz, Yonatan 20124568C
Huasupoma Malca, Enrique 20121046F
Lucas Vargas, Eder 20121011H
Quintanilla Albites, Rubén 20121066G
PROFESOR: Ing. Furukawa Fukuda, Roberto
FECHA DE PRESENTACIÓN: 31/10/2015
![Page 2: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/2.jpg)
LABORATORIO N° 2
PARTE N°1
Ejemplo N°16
Aplicaciones con interrupciones
Código en MPLAB
![Page 3: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/3.jpg)
Ejercicio 1
Generar por el pin RB2 del PIC16F84 una señal de 1KHz (DC=50%) utilizando Interrupciones.
Para generar una señal de 1KHz utilizamos el TMR0 como temporizador. La señal de reloj se obtiene del Cristal de 4MHz (Tclk = 1µs).
Utilizando el pre-escaler (1/2 o Tclk = 2us), con lo cual el TMR0 se llena en 512 µs. Debemos hacer que el TMR0 comience a contar en 6 para que se desborde a los 500 µs.
Habilitamos la Interrupción por desbordamiento (TOIF=1), de ésta manera liberamos al CPU de estar consultando el estado del bit TOIF.
Nota: Hay que poner a ‘0’ el bit TOIF por software. Hay que considerar las instrucciones que se ejecutan entre el salto.
Código MPLAB
![Page 4: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/4.jpg)
Ejemplo N°17
Código en MPLAB
Ejemplo N°18
Código en MPLAB
![Page 5: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/5.jpg)
Ejemplo N°19
Memoria EEPROM de Datos.
Aplicación:
Escribir una sub-rutina para leer un dato de la EEPROM.
El dato leído se debe mostrar en el PORTB.
Utilice la opción: Windows - EEPROM Memory para visualizar el contenido de la EEPROM.
Código en MPLAB
![Page 6: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/6.jpg)
Ejemplo N°20
Memoria EEPROM de Datos.
Aplicación:
Escribir una sub-rutina para escribir un dato de la EEPROM.
Código en MPLAB
![Page 7: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/7.jpg)
Ejemplo N°21
Watch Dog Timer (WDT)
Aplicación:
Utilizando el MPLAB, habilite el WDT y mida el tiempo de generación del RESET.
Código en MPLAB
![Page 8: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/8.jpg)
Ejemplo N°21
Watch Dog Timer (WDT)
Aplicación:
Utilizando el MPLAB, habilite el WDT y mida el tiempo de generación del RESET.
Código en MPLAB
![Page 9: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/9.jpg)
Ejemplo N°22
Modo de Bajo Consumo (SLEEP)
Aplicación:
Escribir un programa que muestre el proceso de recuperación del PIC16F84 del modo SLEEP ante una interrupción externa.
Código en MPLAB
![Page 10: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/10.jpg)
Ejemplo N°23
TMR1 como reloj de tiempo real
Código en MPLAB
![Page 11: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/11.jpg)
Ejemplo N°24
USO del TMR2
Código en MPLAB
![Page 12: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/12.jpg)
Aplicación CCP
CCP (Modo Captura)
Aplicación: Medir el tiempo existente entre los impulsos que llegan al pin RC2/CCP1.
Solución:
- TMR1 como temporizador.
- Modo captura con cada flanco descendente.
- Generar una interrupción en el modo de captura para cargar las variables.
- Multiplicar el valor capturado por el factor del pre-divisor para calcular el tiempo exacto.
Código en MPLAB
![Page 13: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/13.jpg)
Ejemplo N°25
CCP (Modo captura)
Código en MPLAB
![Page 14: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/14.jpg)
CCP (Modo PWM)
Código en MPLAB
![Page 15: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/15.jpg)
DESARROLLO GRUPAL
Memoria Flash y Eeprom (pp 55)
E/S (pp 80)
![Page 16: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/16.jpg)
Temporizadores (pp 93)
CCP (pp 112 y 117)
![Page 17: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/17.jpg)
DESARROLLO GRUPAL
Memoria FLASH y EEPROM
![Page 18: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/18.jpg)
E/S
![Page 19: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/19.jpg)
Temporizadores
![Page 20: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/20.jpg)
CCP
![Page 21: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/21.jpg)
PARTE 2
Secuencia de programación PWM
![Page 22: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/22.jpg)
Conversor A/D
![Page 23: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/23.jpg)
USART
![Page 24: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/24.jpg)
DESARROLLO GRUPAL
AD
![Page 25: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/25.jpg)
COMUNICACIÓN SERIE SINCRONA
![Page 26: LAB2](https://reader035.vdocuments.us/reader035/viewer/2022081603/5695d0001a28ab9b02908021/html5/thumbnails/26.jpg)
USART