Está en la página 1de 4

RELOJ DIGITAL AJUSTABLE DE 6 DISPLAY MOV 56H,#7DH

;------- definicion de puertos MOV 57H,#07H

display EQU P0 MOV 58H,#7FH

;-------interrupcion del reset MOV 59H,#6FH

ORG 0000H ; el 3f es para controlar q sea un


segundo se
AJMP programa_principal
; inicializa en cero
;-------rutina para la interrupcion 0
MOV 3FH,#00H
ORG 0003H
; puerto 2 para controlar que
acall antireb
display esta prendido
acall cero
; se prenden con cero
RETI
MOV P2,#0ffH
;-------rutina de interrupcion del timer 0
; memorias 40,41 son para los
ORG 000BH segundos

ACALL INTERRUPCION MOV 40H,#00H

reti MOV 41H,#00H

;-------Rutina para la interrupción 1 ; memorias 42,43 son para los


minutos
ORG 0013H
mov 42h,#00h
acall antireb
mov 43h,#00h
acall uno
; memorias 44,45 son para las
reti horas
;------Programa principal mov 44h,#00h
ORG 30h mov 45h,#00h
programa_principal: ; todos inician en cero
;guarda los numeros a mostrar en ;------- configuracion del timer 0 para la
el display interrupcion de 10ms
MOV 50H,#3FH SETB EA
MOV 51H,#06H SETB ET0
MOV 52H,#5BH MOV TMOD,#01H
MOV 53H,#4FH MOV TH0,#0DBH
MOV 54H,#66H MOV TL0,#0FFH
MOV 55H,#6DH SETB TR0
;------- configuracion de interrupciones ADD A,#50H
externas
MOV R0,A
; habilitadas por flabnco de bajada
mov a,@r0
SETB P3.2
MOV display,a
SETB P3.3
clr P2.2
SETB EX0
LCALL DELAY
SETB EX1
setb P2.2
SETB IT1

SETB IT0
MOV A,43H
;------- bucle principal
ADD A,#50H
; se muestra aqui constantemente
MOV R0,A
los datos en los displays
mov a,@r0
PRINCIPAL:
MOV display,a
MOV A,40H
clr P2.3
ADD A,#50H
LCALL DELAY
MOV R0,A
setb P2.3
mov a,@r0

MOV display,a
MOV A,44H
clr P2.0
ADD A,#50H
LCALL DELAY
MOV R0,A
setb P2.0
mov a,@r0

MOV display,a
MOV A,41H
clr P2.4
ADD A,#50H
LCALL DELAY
MOV R0,A
setb P2.4
mov a,@r0

MOV display,a
MOV A,45H
clr P2.1
ADD A,#50H
LCALL DELAY
MOV R0,A
setb P2.1
mov a,@r0

MOV display,a
MOV A,42H
clr P2.5 MOV R1,43H

LCALL DELAY CJNE R1,#06H,SALIR

setb P2.5 MOV 43H,#00H

; hora

AJMP PRINCIPAL INC 44H

MOV R1,44H

;------- interrupcion del timer 0 CJNE R1,#0aH,verificar

INTERRUPCION: MOV 44H,#00H

INC 3FH

MOV R1,3FH INC 45H

CJNE R1,#64H,SALIR MOV R1,45H

CPL P2.7 ; led de CJNE R1,#03H,verificar


velocidad de segundos
MOV 45H,#00H
MOV 3FH,#00H
ajmp salir
; segundos
verificar:
INC 40H
mov r1,44h
MOV R1,40H
cjne r1,#4,salir
CJNE R1,#0AH,SALIR
mov r1,45h
MOV 40H,#00H
cjne r1,#2,salir

mov 44h,#0
INC 41H
mov 45h,#0
MOV R1,41H
SALIR:
CJNE R1,#06h,SALIR
MOV TH0,#0DBH
MOV 41H,#00H
MOV TL0,#0FFH
; minuto
ret
INC 42H
;------- interrupcion externa CERO
MOV R1,42H
CERO:
CJNE R1,#0AH,SALIR
INC 44H
MOV 42H,#00H
MOV R1,44H

CJNE R1,#0aH,verificar
INC 43H
MOV 44H,#00H
MOV R3,#0AH

INC 45H Sal0: MOV R4,#0AH

MOV R1,45H Sal1: MOV R5,#0aH

CJNE R1,#03H,verificarEX1 Sal2: DJNZ R5,Sal2

MOV 45H,#00H DJNZ R4,SAL1

ajmp salirex1 DJNZ R3,SAL0

RET

verificarEX1: ;------ DELAY para mostrar en los displays

mov r1,44h DELAY:

cjne r1,#4,salirex1 MOV R7,#0FAH

mov r1,45h MOV R6,#01H

cjne r1,#2,salirex1 BUC: DJNZ R7,BUC

mov 44h,#0 MOV R7,#0FAH

mov 45h,#0 DJNZ R6,BUC

salirex1: NOP

ret RET

;------- interrupcion externa UNO END

UNO:

INC 42H

MOV R1,42H

CJNE R1,#0AH,SALIRex0

MOV 42H,#00H

INC 43H

MOV R1,43H

CJNE R1,#06H,SALIRex0

MOV 43H,#00H

salirex0:

ret

;------- DELAY del antirebotes

antireb:

También podría gustarte