Design of Single Chip Microcomputer Electronic Clock

Publisher:BlossomWhisperLatest update time:2012-12-31 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Here is a 51 single-chip electronic clock assembly program design method:

org 00h
a_bit equ 30h ; second register
b_bit equ 31h ; 10
second register
c_bit equ 32h ; minute register d_bit equ 33h ; 10 minute register
e_bit equ 34h ; hour register
f_bit equ 35h ; 10 hour register

org 0000h
ajmp star
org 0030h

star:
mov a,#00h ; clear all bits to 0
mov a_bit,a
mov b_bit,a
mov c_bit,a
mov d_bit,a
mov e_bit,a
mov f_bit,a
stlop: acall display ; calculation part of 51 single-chip electronic clock program

inc a_bit ;add 1 to the second bit
mov a,a_bit ;send a
cjne a,#10,stlop;if the second reaches 10, then go to 10 seconds processing
mov a_bit,#00h ;clear the second bit to 0
inc b_bit ;add 1 to the 10 seconds
bit mov a,b_bit ;send a
cjne a,#6,stlop ;if the 10 seconds reaches 6, then go to minute processing
mov b_bit,#00h ;clear the 10 seconds bit to 0
inc c_bit
mov a,c_bit
cjne a,#10,stlop
mov c_bit, #00h
inc d_bit
mov a,d_bit
cjne a,#6,stlop
mov d_bit,#00h
inc e_bit
mov a,e_bit
cjne a,#10,stlop
mov e_bit,#00h
inc f_bit
mov a,f_bit
cjne a,#3,stlop
mov f_bit,#00h
ajmp stlop ; restart calculation

display: ;Display subroutine - 51 single-chip electronic clock directly displayed on the seven-segment digital tube
mov dptr,#numtab ;Specify the start address of the table lookup
mov r0,#4
dpl1: mov r1,#250 ;Display 1000 times
dplop: mov a,a_bit ;Get the value of the second digit
MOVC A,@A+DPTR ;Look up the 7-segment code of the second digit
mov p0,a ;Send to P0 port for display
clr p2.6 ;Open the unit digit display
acall d1ms ;Display 1ms
setb p2.6 ;Turn off the display

mov a,b_bit ;get the value of the 10-second bit
MOVC A,@A+DPTR ;check the 7-segment code of the 10-second bit
mov p0,a ;send the 10-second bit to port P0 for display

clr p2.5 ; open 10 seconds display
acall d1ms ; display 1ms
setb p2.5

mov a,c_bit ; get the bit position
MOVC A,@A+DPTR;

mov p0,a ;
clr p2.4 ;
acall d1ms ;

setb p2.4

mov a,d_bit ; take 10th bit
MOVC A,@A+DPTR ;

mov p0,a ;

clr p2.3 ;

acall d1ms ;

setb p2.3

mov a,e_bit ; get hour bit
MOVC A,@A+DPTR ;
mov p0,a ;
clr p2.2 ;
acall d1ms ;

setb p2.2

mov a,f_bit ; get 10 hours bit
MOVC A,@A+DPTR ;
mov p0,a ;
clr p2.1 ;
acall d1ms ;
setb p2.1

djnz r1,dplop ;100 endless loops
djnz r0,dpl1 ;4 100 endless loops
ret
D1MS: MOV R7,#20 ;1MS delay (calculated as 12MHZ)
DJNZ R7,$
RET
;Digital arrangement table of each stroke of the seven-segment digital tube - http://www.51hei.com/ provides
numtab: db 28h,7eh,0a2h,62h,74h,61h,21h,7ah,20h,60h
;0 1 2 3 4 5 6 7 8 9
end

Reference address:Design of Single Chip Microcomputer Electronic Clock

Previous article:Design of MCU Cycle Light Assembly Program
Next article:Design of an indoor intelligent monitoring system

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号