Electronic clock assembly program with digital tube display

Publisher:AngelicHeartLatest update time:2015-07-27 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
;****************************************************** ************
;Function:
;Realize electronic clock display (assembly)
;definition:
; P3 port position selection, P1 port segment selection, P0.0, P0.1, P0.2 are timing ports
;time:
; 2010-11-26
;****************************************************** ************

 

SECOND EQU 30H

MINITE EQU 31H

HOUR EQU 32H

HOURK BIT P0.0

MINITEK BIT P0.1

SECONDK BIT P0.2

DISPBUF EQU 40H

DISPBIT EQU 48H

T2SCNTA EQU 49H

T2SCNTB EQU 4AH

TEMP EQU 4BH

 

ORG 00H

LJMP START

ORG 0BH

LJMP INT_T0

 

START:

       MOV SECOND,#00H

       MOV MINITE,#00H

       MOV HOUR,#12

       MOV DISPBIT,#00H

       MOV T2SCNTA,#00H

       MOV T2SCNTB,#00H

       MOV TEMP,#0FEH

       LCALL DISP

       MOV TMOD,#01H

       MOV TH0,#(65536-2000) / 256

       MOV TL0,#(65536-2000) MOD 256

       SETB TR0

       SETB ET0

       SETB EA

 

WT:

       JB SECONDK,NK1

       LCALL DELY10MS

       JB SECONDK,NK1

       INC SECOND

       MOV A,SECOND

       CJNE A,#60,NS60

       MOV SECOND,#00H

 

NS60:

       LCALL DISP

       JNB SECONDK,$

 

NK1:

       JB MINITEK,NK2

       LCALL DELY10MS

       JB MINITEK,NK2

       INC MINITE

       MOV A,MINITE

       CJNE A,#60,NM60

       MOV MINITE,#00H

 

NM60:

       LCALL DISP

       JNB MINITEK,$

 

NK2:

       JB HOURK,NK3

       LCALL DELY10MS

       JB HOURK,NK3

       INC HOUR

       MOV A,HOUR

       CJNE A,#24,NH24

       MOV HOUR,#00H

 

NH24:

       LCALL DISP

       JNB HOURK,$

 

NK3:

       LJMP WT

 

DELY10MS:

       MOV R6,#10

 

D1:

       MOV R7,#248       

       DJNZ R7,$

       DJNZ R6,D1

       RET
[page]
 

DISP:

       MOV A,#DISPBUF

       ADD A,#8

       DEC A

       MOV R1,A

       MOV A,HOUR

       MOV B,#10

       DIV AB

       MOV @R1,A

       DEC R1

       MOV A,B

       MOV @R1,A

       DEC R1

       MOV A,#10

       MOV@R1,A

       DEC R1

       MOV A,MINITE

       MOV B,#10

       DIV AB

       MOV @R1,A

       DEC R1

       MOV A,B

       MOV @R1,A

       DEC R1

       MOV A,#10

       MOV@R1,A

       DEC R1

       MOV A,SECOND

       MOV B,#10

       DIV AB

       MOV @R1,A

       DEC R1

       MOV A,B

       MOV @R1,A

       DEC R1

       RET

 

INT_T0:

       MOV TH0,#(65536-2000) / 256

       MOV TL0,#(65536-2000) MOD 256

       MOV A,#DISPBUF

       ADD A, DISPBIT

       MOV R0,A

       MOV A,@R0

       MOV DPTR,#TABLE

       MOVC A,@A+DPTR

       MOV P1,A

       MOV A,DISPBIT

       MOV DPTR,#TAB

       MOVC A,@A+DPTR

       MOV P3,A

       INC DISPBIT

       MOV A,DISPBIT

       CJNE A,#08H,KNA

       MOV DISPBIT,#00H

 

KNA:

       INC T2SCNTA

       MOV A,T2SCNTA

       CJNE A,#100,DONE

       MOV T2SCNTA,#00H

       INC T2SCNTB

       MOV A,T2SCNTB

       CJNE A,#05H,DONE

       MOV T2SCNTB,#00H

       INC SECOND

       MOV A,SECOND

       CJNE A,#60,NEXT

       MOV SECOND,#00H

       INC MINITE

       MOV A,MINITE

       CJNE A,#60,NEXT

       MOV MINITE,#00H

       INC HOUR

       MOV A,HOUR

       CJNE A,#24,NEXT

       MOV HOUR,#00H

 

NEXT:

       LCALL DISP

 

DONE:

       RETI

 

TABLE:

       DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,40H

 

TAB:

       DB 0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FH

 

END
//Source code download: http://www.51hei.com/f/sza511.rar
Reference address:Electronic clock assembly program with digital tube display

Previous article:Ultrasonic reverse collision avoidance system based on single chip microcomputer design
Next article:The stepper motor with the pointer moves on the ruler and displays the coordinates and relative coordinates

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号