Está en la página 1de 3

PROGRAMA EN ENSAMBLADOR

LIST P=16F84AINCLUDE <P16F84A.INC>

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC


CBLOCK 0x0C
CicloTrabajo
GuardaValor
GuardaEntrada
Timer0_ContadorA
ENDC

TMR0_Carga EQU d'256'-d'245'


MAX_ENTRADA EQU .16#DEFINE SalidaMarcha PORTA,3
ORG 0
goto Inicio
ORG 4
goto Timer0_Interrupcion
Mensajes
addwf PCL,F
Mensaje0
DT " VELOCIDAD", 0x00

Inicio
call LCD_Inicializa
movlw Mensaje0
call LCD_Mensaje
bsf STATUS,RP0
bcf SalidaMarcha
movlw b'11110000'
movwfPORTB
movlw b'00000001'
movwfOPTION_REG
bcf STATUS,RP0
bcf SalidaMarcha
Principal
TesteaVelocidad
movf PORTB,W
swapf PORTB,W
movwfGuardaValor
andlw b'00001111'
movwfGuardaEntrada
btfsc STATUS,Z
goto DC_CeroPorCiento
sublw MAX_ENTRADA
btfsc STATUS,Z
goto DC_100PorCiento
btfss STATUS,C
goto DC_CeroPorCiento
movf GuardaEntrada,W
movwfCicloTrabajo
movlw b'10100000'
movwfINTCON
goto Fin
DC_CeroPorCiento
bcf SalidaMarcha
goto InhabilitaInterrupcion
DC_100PorCiento
bsf SalidaMarcha
InhabilitaInterrupcion
clrf INTCON
Fin goto Principal;Subrutina " visualixa velocidad"---
;
visualixa
movlw .6
call LCD_PosicionLinea2
clrw
swapf PORTB,W
call BIN_a_BCD
call LCD_Byte
return

; Subrutina "Timer0_Interrupcion" ----


;
;
;
CBLOCK
Guarda_W
Guarda_STATUS
ENDC

Timer0_Interrupcion
movwf
Guarda_W
swapf STATUS,W
movwfGuarda_STATUS
bcf STATUS,RP0
movlw TMR0_Carga
movwf TMR0
decfsz Timer0_ContadorA,F
goto Fin_Timer0_Interrupcion
btfsc SalidaMarcha
goto EstabaAlto
EstabaBajo
bsf SalidaMarcha
call visualixa
movf CicloTrabajo,W
movwf Timer0_ContadorA
goto Fin_Timer0_Interrupcion
EstabaAlto
bcf SalidaMarcha
call visualixa
movf CicloTrabajo,W
sublw .16
movwf Timer0_ContadorA
Fin_Timer0_Interrupcion
swapf GuardaValor,W
movwfPORTB
swapf Guarda_STATUS,W
movwfSTATUS
swapf Guarda_W,F
swapf Guarda_W,W
bcf INTCON,RBIF
bcf INTCON,T0IF
retfie

INCLUDE <RETARDOS.INC>
INCLUDE <BIN_BCD.INC>
INCLUDE <LCD_4BIT.INC>
INCLUDE <LCD_MENS.INC>
END

También podría gustarte