P1 EQU 090H ;----- initialized seven segment display
P3 EQU 0B0H ;----- initialized buzzer
B EQU 0F0H ;----- initialized B
;=============================================================================================
MAIN:
MOV R0,#24 ;initialize R0 to 24
;=============================================================================================
START:
MOV A,R0 ;move to the accumulator
MOV B,#10 ;move the value of 10 to B
DIV AB ;divide A by B, and ans qoutient to A and remainder to B
LCALL DISPLAY ;call the pattern to start counting
SETB P3.5 ;enable the 2nd digit for display
MOV P1,A ;enable the 1st digit for display
CLR P3.5 ;clear to disable the 2nd digit display
MOV R4,B ;move the remainder in B to register R4
MOV A,R4 ;move the register R4 to accumulator
LCALL DISPLAY ;call pattern
MOV P1,A ; display the second digit pattern
MOV R1,#0 ;initialized R1 to 0
MOV R2,#0 ;initialized R2 to 0
MOV R3,#7 ;initialized R3 to 7
CJNE R0,#0,DELAY ;jump to DELAY if R0 is not equal to 0
SJMP BUZZ ; if R0 is already 00, jump to BUZZER
;==============================================================================================
DISPLAY: ;subroutine for driving LED Display
INC A ;increment the current value in Accumulator
MOVC A,@A+PC ;Register Indexed Addressing mode
RET
; hex form of 0 to 9
DB 0C0H ;0
DB 0F9H ;1
DB 0A4H ;2
DB 0B0H ;3
DB 99H ;4
DB 92H ;5
DB 82H ;6
DB 0F8H ;7
DB 80H ;8
DB 90H ;9
;==============================================================================================
DELAY:
DJNZ R1, DELAY ;delay of 1 second before displaying the next pattern
DJNZ R2, DELAY
DJNZ R3, DELAY
DEC R0 ;decrementing R0
SJMP START
;==============================================================================================
BUZZ:
MOV R1,#500 ;initializing R1
MOV R2,#500
BUZZ_1:
CLR P3.7 ;setting 1 for output port P3.7
DJNZ R1,BUZZ_1 ;setting delay for setting port P3.7 to zero
BUZZ_2:
SETB P3.7 ;setting 0 for output port P.3.7
DJNZ R2,BUZZ_2 ;setting delay for setting port P3.7 to one
SJMP BUZZ ;infinite loop for enabling buzzer
END
;===============================================================================================
No comments:
Post a Comment
Thanks for Suggestion / Comment!
God Bless!