Está en la página 1de 3

;Reloj

list p=16f877a
include "p16f877a.inc"

; CONFIG
; __config 0xFF39
__CONFIG _FOSC_XT & _WDTE_OFF & _PWRTE_OFF & _BOREN_OFF & _LVP_OFF & _CPD_OFF &
_WRT_OFF & _CP_OFF

VarCuartoDeSegundo EQU 0X20


VarContadorMilisegundo EQU 0X21
VarAux EQU 0X22
VarSegundos EQU 0X23
VarMinutos EQU 0X24
VarHoras EQU 0X25

org 0x00

goto INICIO

org 0x04
;INTERRUPCION
bcf INTCON,7
btfsc INTCON,1
call InterrupcionPorRB0
bsf INTCON,7
;goto INTERRUPCION
retfie

InterrupcionPorRB0
bcf INTCON,1
incf VarAux,f
movfw VarAux
movwf PORTA
return

INICIO
;Configuracion TMR0
bsf STATUS,RP0
bcf STATUS,RP1
movlw b'00000001'
movwf OPTION_REG
;Configuracion Puertos
clrf TRISA
clrf TRISC
;Desabilitar Conversor A/D
bcf STATUS,RP0
bcf ADCON0,0
;Configurar Pines Del puerto A Como I/O Digitales
bsf STATUS,RP0
movlw b'00000111'
movwf ADCON1
;Configuracion De Interrupciones
bcf STATUS,RP0
bsf INTCON,7
bcf INTCON,6
bcf INTCON,5
bsf INTCON,4
bcf INTCON,3

;Limpiar Puertos Y Variables


clrf PORTA
clrf PORTB
clrf PORTC
clrf VarCuartoDeSegundo
clrf VarContadorMilisegundo
clrf VarAux
clrf VarSegundos
clrf VarMinutos
clrf VarHoras

MENU_PRINCIPAL
ContadorSegundos
bcf INTCON,T0IF
movlw d'6'
movwf TMR0
EsperarMilisegundo
btfss INTCON,T0IF
goto EsperarMilisegundo
incf VarContadorMilisegundo,f
movlw d'250'
xorwf VarContadorMilisegundo,w
btfss STATUS,Z
goto ContadorSegundos
clrf VarContadorMilisegundo
incf VarCuartoDeSegundo,f
movlw d'4'
xorwf VarCuartoDeSegundo,w
btfss STATUS,Z
goto ContadorSegundos
clrf VarCuartoDeSegundo
incf VarSegundos,f
movfw VarSegundos
movwf PORTC
movlw d'60'
xorwf VarSegundos,w
btfss STATUS,Z
goto ContadorSegundos
clrf VarSegundos
incf VarMinutos,f
;movfw VarMinutos
;movwf PORTA
movlw d'60'
xorwf VarMinutos,w
btfss STATUS,Z
goto ContadorSegundos
clrf VarMinutos
incf VarHoras,f
movlw d'24'
xorwf VarHoras
btfss STATUS,Z
goto ContadorSegundos
clrf VarHoras
goto ContadorSegundos
goto MENU_PRINCIPAL

END

También podría gustarte