Esta practica la armamos en el lenguaje ensamblador (.asm) debido a que se nos hizo mas practica la realización en este lenguaje, a continuación se muestra el código realizado:
list p=16F628A ; list directive to define processor
#include <p16F628A.inc> ; processor specific variable definitions errorlevel -302 ; suppress message 302 from list file __CONFIG _CP_OFF & DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT CBLOCK 0x20 Registro50ms ENDC CARGA_500ms EQU d'15' TMR0_Carga50ms EQU d'256'-d'24' #DEFINE LED PORTB,1 ORG 0 goto Inicio ORG 4 goto Timer0_Interrupcion Inicio movlw .7 movwf CMCON call LCD_Inicializa bsf STATUS,RP0 bcf LED movlw b'00000000' movwf OPTION_REG ; Prescaler de 2 para el TMR0 bcf STATUS,RP0 movlw TMR0_Carga50ms ; Carga el Timer 0. movwf TMR0 movlw CARGA_500ms movwf Registro50ms ; Número de veces a repetir la interrupción. movlw b'10100000' ; Activa interrupción del TMR0 (TOIE) y la movwf INTCON ; general (GIE). Principal movlw MensajeLargo call LCD_MensajeMovimiento goto Principal CBLOCK Guarda_W Guarda_STATUS ENDC Timer0_Interrupcion movwf Guarda_W ; Guarda W y STATUS. swapf STATUS,W movwf Guarda_STATUS bcf STATUS,RP0 ; Para asegurarse de que trabaja con el banco 0. movlw TMR0_Carga50ms movwf TMR0 ; Recarga el TMR0. decfsz Registro50ms,F ; Decrementa el contador. goto FinInterrupcion movlw CARGA_500ms ; Repone el contador nuevamente. movwf Registro50ms btfsc LED ; Pasa a conmutar el estado del LED. goto EstabaEncendido EstabaApagado bsf LED ; Lo enciende. goto FinInterrupcion EstabaEncendido bcf LED ; Lo apaga. FinInterrupcion swapf Guarda_STATUS,W ; Restaura el STATUS. movwf STATUS swapf Guarda_W,F ; Restaura W como estaba antes de producirse swapf Guarda_W,W ; la interrupción. bcf INTCON,T0IF retfie Mensajes addwf PCL,F MensajeLargo DT " " DT "Garcia Fragoso Jordan Adrian." DT " ", 0x00 ; INCLUDE <LCD_MENS.INC> INCLUDE <LCD_4BIT.INC> INCLUDE <RETARDOS.INC> END |
Despues de hacerlo en .asm lo realizamos en PicBasic, ya que de esto es la materia, y para esto este es nuestro codigo para PicBasic:
'****************************************************************
'* Name
: UNTITLED.BAS *
'* Author
: [select VIEW...EDITOR OPTIONS] *
'* Notice
: Copyright (c) 2013 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date
: 18/02/2013 *
'* Version : 1.0
*
'* Notes
:
*
'* :
*
'****************************************************************
@
DEVICE 3F10H
CMCON=7
DEFINE
OSC 4
Z
VAR BYTE
W
VAR BYTE
Y
VAR BYTE
Z
= 0
TRISB
= $00
TRISA
= $00
ON
INTERRUPT GOTO Int
SYMBOL
TOIF=INTCON.2 : SYMBOL SALIDA=PORTA.1
SALIDA=0
H
CON 010010
O
CON %10000000
A
CON 010000
L
CON %10001110
OPTION_REG=000000
INTCON=%10100000
TMR0=233
Inicio:
portb=H
CALL
time
portb=O
CALL
time
portb=l
CALL
time
portb=a
CALL
time
goto
IniciO
time:
for
w=1 to 100
pause
5
next
return
DISABLE
Int:
TOGGLE
SALIDA
GOTO RESETEO
RETRASO:
FOR
Z=1 TO 25
CALL
RETARDO
NEXT
RETURN
RETARDO:
TMR0=233
Espera:
if
toif=1 then RESETEO
GOTO
ESPERA
RESETEO:
TOIF=0
TMR0=233
INTCON=%10100000
RETURN
RESUME
END
|
Para esto se llevo a cabo la simulación que nos permite ver el funcionamiento de nuestro programa antes de hacer el físico
Para comprobar el funcionamiento, revisa el siguiente enlace:
http://www.youtube.com/watch?v=0W7iTMtDxcA
http://www.youtube.com/watch?v=0W7iTMtDxcA
muy buena publicación fue de mucha ayuda gracias y sigue así colega :)
ResponderEliminar